Create-react-app: Mac OS test watcher failing

Created on 26 Mar 2018  路  7Comments  路  Source: facebook/create-react-app

Is this a bug report?

I believe this is a bug. I'm just not sure who's?

Did you try recovering your dependencies?

I have tried this by using only npm.

Which terms did you search for in User Guide?

Error watching file for changes: EMFILE

Environment

  1. node -v: 8.10.0 and 9.9.0
  2. npm -v: 5.7.1
  3. yarn --version (if you use Yarn):
  4. npm ls react-scripts (if you haven鈥檛 ejected):

Then, specify:

  1. Operating system: Mac OS High Siera
  2. Browser and version (if relevant):

Steps to Reproduce

https://github.com/mnemanja/failing-tests-repo

  1. Clone repo
  2. Install
  3. Run tests

From the list of 3 (currently found) problematic dependencies removing one makes the tests watcher work properly:

  • node-sass-chokidar: 1.2.2
  • material-ui: 0.20.0
  • enzyme: 3.3.0

Expected Behavior

Tests should be successfully executed and the watch mode should be active.

Actual Behavior

The watch mode exists and error messages are shown.

Reproducible Demo

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.

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.

All 7 comments

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,

  1. export CI=true before you run the tests
  2. in package.json you can add the coverage flag "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 :) 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alleroux picture alleroux  路  3Comments

alleroux picture alleroux  路  3Comments

jnachtigall picture jnachtigall  路  3Comments

AlexeyRyashencev picture AlexeyRyashencev  路  3Comments

barcher picture barcher  路  3Comments