Thursday, June 14, 2018

Error with reactjs App.test.js

Leave a Comment

I get this error while trying to run npm.test for the App.test.js that you get when installing reactjs. Any thoughts on how to solve this? I've added some extra code etc now.

> client@0.1.0 test /Users/filipmyllari/Documents/1DV430/fm222hp-  project/client react-scripts test --env=jsdom  >2018-05-29 16:26 node[535] (FSEvents.framework) FSEventStreamStart:  register_with_server: ERROR: f2d_register_rpc() => (null) (-22) 2018-05-29 16:26 node[535] (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:1019:11) at FSEvent.FSWatcher._handle.onchange (fs.js:1360:9) npm ERR! Test failed.  See above for more details. 

Here is the package.json file

{  "name": "client",  "version": "0.1.0",  "private": true,  "dependencies": {  "add": "^2.0.6",  "babel-jest": "^23.0.1",  "babel-preset-env": "^1.7.0",  "babel-preset-react": "^6.24.1",  "firebase": "^4.13.1",  "jest": "^23.0.1",  "lodash": "^4.17.5",  "react": "^16.3.1",  "react-dom": "^16.3.1",  "react-router-dom": "^4.2.2",  "react-scripts": "1.1.4",  "react-test-renderer": "^16.4.0",  "yarn": "^1.7.0"  },  "scripts": {  "start": "react-scripts start",  "build": "react-scripts build",  "test": "react-scripts test --env=jsdom",  "eject": "react-scripts eject" }, "devDependencies": {  "enzyme": "^3.3.0",  "react-addons-test-utils": "^15.6.2" } } 

The code comes below here (App.test.js)

import React from 'react' import ReactDOM from 'react-dom' import App from './App'  it('renders without crashing', () => {   const div = document.createElement('div')   ReactDOM.render(<App />, div) })  describe('Addition', () => {   it('knows that 2 and 2 make 4', () => {     expect(2 + 2).toBe(4);   }); }); 

1 Answers

Answers 1

This is a common problem when facing testing with Jest.

I would suggest you installing watchman as proposed in Jest issue 1767.

brew install watchman 

After installing any test should go without a problem, it has resolved such problems on my and some of my work colleagues computers so I believe it can be also worth trying for you.


Furthermore some latest response on issue suggest updating Jest to omit the error:

Ultimately, updating to Jest 23.1.0 resolved the issue. (releaf)

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment