Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac OS test watcher failing #4215

Closed
mnemanja opened this issue Mar 26, 2018 · 7 comments
Closed

Mac OS test watcher failing #4215

mnemanja opened this issue Mar 26, 2018 · 7 comments

Comments

@mnemanja
Copy link

mnemanja commented Mar 26, 2018

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’t 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:
michaelwayman/node-sass-chokidar#50
enzymejs/enzyme#1593
mui/material-ui#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.

@michaelwayman
Copy link
Contributor

michaelwayman commented Mar 26, 2018

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..

@mnemanja
Copy link
Author

@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.

@adambowles
Copy link
Contributor

What errors are being printed?

Could it be this? nodejs/node#15683
(Solved for me by installing watchman: brew install watchman)

@mnemanja
Copy link
Author

mnemanja commented Mar 29, 2018

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)

@yashka713
Copy link

@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?

@gaearon
Copy link
Contributor

gaearon commented Apr 3, 2018

This problem was solved in more recent Jest versions, which you can use through our 2.x alpha.
Instructions: #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.

@gaearon gaearon closed this as completed Apr 3, 2018
@mnemanja
Copy link
Author

Thanks,
now it works like a charm :) 👍

mynameistechno pushed a commit to codeauroraforum/website that referenced this issue Jul 20, 2018
We need to use `react-scripts` 2+ to be able to use jest + enzyme, per
facebook/create-react-app#4215 (comment)
They won't be fixing it for `react-scripts` 1.x branch.

Signed-off-by: Mark Matyas <[email protected]>
mynameistechno pushed a commit to codeauroraforum/website that referenced this issue Aug 14, 2018
We need to use `react-scripts` 2+ to be able to use jest + enzyme, per
facebook/create-react-app#4215 (comment)
They won't be fixing it for `react-scripts` 1.x branch.

Signed-off-by: Mark Matyas <[email protected]>
@lock lock bot locked and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants