small medium large xlarge

Back to: All Forums  React for Real
Kel_pragsmall
04 Sep 2017, 20:59
Kel Cecil (1 post)

I’m really enjoying React for Real so far, but I ran into an issue people may run into in Chapter 4. I received an error that looked like the following:

Determining test suites to run...Error: This promise must be present when running with -o.
    at /Users/kelcecil/code/react-for-real/wordcounter-single/node_modules/jest/node_modules/jest-cli/build/search_source.js:192:17
    at Generator.next (<anonymous>)
    at step (/Users/kelcecil/code/react-for-real/wordcounter-single/node_modules/jest/node_modules/jest-cli/build/search_source.js:20:362)
...

There appears to be a bug in Jest v21.0.1 where you’ll see this error if you run jest --watch in a directory without a git metadata (.git) directory. You can workaround by running git init in your project directory to create the git metadata directory or by downgrading Jest to v20.0.4.

You can follow the relevant bug report at Github. Hope this helps!

Generic-user-small
04 Sep 2017, 21:19
Ludovico Fischer (9 posts)

Thank you for your report. It definitely looks like a Jest bug, so let’s hope they fix it soon. Luckily Jest 21 was released just 6 hours ago, so the damage windows should be small. Real breakage will probably occur with Enzyme once Enzyme 3 releases for React 16 compatibility; but I am not sure API changes are definitive yet.

Generic-user-small
23 Nov 2017, 02:01
Stanford Guillory (2 posts)

A workaround for this bug is to use -watchAll instead of -watch.

Generic-user-small
23 Nov 2017, 18:42
Ludovico Fischer (9 posts)

Jest merged a fix for this a few days ago: https://github.com/facebook/jest/pull/4865 Hopefully they’ll release it soon.

Generic-user-small
06 Jan 2018, 13:25
Balaji Raghavan (2 posts)

With version 3.0 of Enzyme, you have to connect to an adapter. Please check https://github.com/airbnb/enzyme#upgrading-from-enzyme-2x-or-react–16 on how to fix it.


import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({ adapter: new Adapter() });
import { shallow } from 'enzyme';

Adding this somewhere before the tests should fix it.

Generic-user-small
08 Jan 2018, 19:38
Balaji Raghavan (2 posts)

Test ‘displays the correct count as a number’ may not pass. As the counter is not re-rendered. Try and call update on the wordCounter component.

For e.g.

  it('displays the correct count as a number', () => {
    wordCounter.update();
    const counter = wordCounter.find(Counter);
    expect(counter.prop('count')).toBe(countWords(inputString));
  });
Generic-user-small
08 Jan 2018, 21:42
Ludovico Fischer (9 posts)

I posted on how to update the tests for Enzyme 3 and React 16 in this forum thread https://forums.pragprog.com/forums/397/topics/15499

You must be logged in to comment