I believe this is a bug. I'm just not sure who's?
I have tried this by using only npm.
Error watching file for changes: EMFILE
node -v: 8.10.0 and 9.9.0npm -v: 5.7.1yarn --version (if you use Yarn):npm ls react-scripts (if you haven鈥檛 ejected): Then, specify:
https://github.com/mnemanja/failing-tests-repo
From the list of 3 (currently found) problematic dependencies removing one makes the tests watcher work properly:
Tests should be successfully executed and the watch mode should be active.
The watch mode exists and error messages are shown.
https://github.com/mnemanja/failing-tests-repo
I have also created similar reports on all involved repos:
https://github.com/michaelwayman/node-sass-chokidar/issues/50
https://github.com/airbnb/enzyme/issues/1593
https://github.com/mui-org/material-ui/issues/10801
I have tried installing the Watchman via brew, as per many suggestions found in this repo and several others, but after the installation, nothing has changed.
This is coming from react-scripts test.js
// Watch unless on CI or in coverage mode
if (!process.env.CI && argv.indexOf('--coverage') < 0) {
argv.push('--watch');
}
Where the --watch argument is being added to jest.
There are 2 workarounds for now,
export CI=true before you run the tests"test": "react-scripts test --env=jsdom --coverage"But as of yet I am not sure why the jest watch flag in combination with those packages would break the jest tests..
@michaelwayman The point is to have the tests run in the watch mode, which currently doesn't happen.
Exporting CI=true and setting coverage removes not only the error but the watch mode as well.
What errors are being printed?
Could it be this? https://github.com/nodejs/node/issues/15683
(Solved for me by installing watchman: brew install watchman)
That's the error and the watchman didn't fix it.
2017-10-02 11:38 node[63244] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-10-02 11:38 node[63244] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:182
throw er; // Unhandled 'error' event
^
Error: Error watching file for changes: EMFILE
at _errnoException (util.js:1021:13)
at FSEvent.FSWatcher._handle.onchange (fs.js:1369:9)
@mnemanja brew install watchman solve my problem, but before I had the same Issue.
"test": "react-scripts test --env=jsdom I, also, have this line
Maybe, you should remove
node_modules
yarn.lock
package.json.lock(if present)
And start yarn to recreate dependency?
This problem was solved in more recent Jest versions, which you can use through our 2.x alpha.
Instructions: https://github.com/facebook/create-react-app/issues/3815
Unfortunately there's no fix coming for the 1.x branch of react-scripts. So your best bet is to either start using 2.x alphas (warning: they're somewhat unstable) or to keep trying different workarounds in the threads you linked to.
Thanks,
now it works like a charm :) 馃憤
Most helpful comment
This problem was solved in more recent Jest versions, which you can use through our 2.x alpha.
Instructions: https://github.com/facebook/create-react-app/issues/3815
Unfortunately there's no fix coming for the 1.x branch of
react-scripts. So your best bet is to either start using 2.x alphas (warning: they're somewhat unstable) or to keep trying different workarounds in the threads you linked to.