facebook/create-react-app

Tests hang when running

luizkowalski opened this issue · 19 comments

I have a test like this:

test('renders without crashing', () => {
  // const div = document.createElement('div');
  // ReactDOM.render(<App />, div);
  expect(true).toBe(true)
});

when I run it, with npm t it hangs. here is the output

→ npm t --loglevel=silly
npm info it worked if it ends with ok
npm verb cli [ '/usr/local/Cellar/node/6.6.0/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   't',
npm verb cli   '--loglevel=silly' ]
npm info using npm@3.10.7
npm info using node@v6.6.0
npm verb run-script [ 'pretest', 'test', 'posttest' ]
npm info lifecycle reg-dashboard@0.1.0~pretest: reg-dashboard@0.1.0
npm sill lifecycle reg-dashboard@0.1.0~pretest: no script for pretest, continuing
npm info lifecycle reg-dashboard@0.1.0~test: reg-dashboard@0.1.0

> reg-dashboard@0.1.0 test /Users/luizeduardo/js_dev/reg-dashboard
> react-scripts test --env=jsdom

I'm running macOS Sierra with.
I can reproduce it with a new app as well.

the react-scripts:

→ npm ls react-scripts
reg-dashboard@0.1.0 /Users/luizeduardo/js_dev/reg-dashboard
├── react-scripts@0.4.1
``

By "hangs" do you mean that interactive watcher never appears?

As mentioned in jestjs/jest#1767 (comment), can you try running

brew install watchman

?

@gaearon yes, as the log above, I see > react-scripts test --env=jsdom as the last output, and nothing else happens. I tried edit the test files, change the __tests__ folder location, or have just one simple test like expect(true).toBe(true)
I do have watchmen installed, btw.

I meant to run this command to update it to 4.7.0 (as explained in jestjs/jest#1767 (comment)).

I do have watchmen 4.7.0 installed

I see. Can you reproduce this on any other computer (with or without Sierra)?

I think it would be best if you shared your report in jestjs/jest#1767 to provide more context around this issue.

It’s also worth trying to uninstall watchmen and seeing if that fixes the issue.

uninstall watchman fixed!

Can you try to install it again now and see if the problem persists? If it does, please also try suggestions in jestjs/jest#1767 (comment) and let us know if either worked.

Just did, yes, the problem persists if I reinstall.

Does doing this help?

launchctl unload ~/Library/LaunchAgents/com.github.facebook.watchman.plist
watchman version

(and then run tests)

Another workaround worth trying is to delete /usr/local/var/run/watchman/<USER>-state and try again.

Closing as this is a problem with watchman, and can’t be resolved here. Uninstalling watchman is a reasonable workaround in the meantime.

Hey, sorry for the delay.
No, unload didn't worked for me, anyway.
Thanks!

I’d appreciate if you could report this upstream to Jest or watchman.

dmr commented

I ran into this and it took me a while to find this issue. --> Can we mention this in the docs somewhere?

Sure, a PR to the User Guide with troubleshooting steps would be welcome.

A few other reported ways to fix it: