michaelwayman / node-sass-chokidar

A thin wrapper around node-sass to replicate the --watch using chokidar instead of Gaze

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tests started failing after installing this dependency on Mac OS

mnemanja opened this issue · comments

My setup

OS: Mac OS High Siera (works on Ubuntu)
node: 8.10.0
npm: 5.7.1
create-react-app: 1.1.1
material-ui: 0.20.0
enzyme: 3.3.0
enzyme-adapter-react-16: 1.1.1
node-sass-chokidar: 1.2.2

When I add the node-sass-chokidar library, the tests watching fails. So, just having it in the node_modules breaks the tests.

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

2018-03-26 13:53 node[9085] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2018-03-26 13:53 node[9085] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: Error watching file for changes: EMFILE
    at _errnoException (util.js:1022:11)
    at FSEvent.FSWatcher._handle.onchange (fs.js:1359:9)
npm ERR! Test failed.  See above for more details.

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

Referenced here as well
facebook/create-react-app#4215

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

Unfortunately I don't think there is anything that I can do on the node-sass-chokidar side to fix this.