Some part of the tutorial breaks the tests included in create-react-app
The tests included in create-react-app do not work if you follow this tutorial to the end. create-react-app tests work fine for me when I first generate a project, but for the code I built using this tutorial the very basic tests (just test to see if a component loaded up on a page) break.
I mentioned this in the comment section of "Wrapping Up" and got confirmation from @jayair that his tests were broken as well. (though he had a different error message).
My original post explaining the problem:
I didn't run any tests during this tutorial, and by the end of it, the standard create-react-app tests are broken for me. Running "npm test" yields:
> [email protected] test /Users/Bazo/serverlessReact/notes-app-client
> react-scripts test --env=jsdom
2018-04-04 15:24 node[65744] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2018-04-04 15:24 node[65744] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2018-04-04 15:24 node[65744] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:160
throw er; // Unhandled 'error' event
^
Error: Error watching file for changes: EMFILE
at exports._errnoException (util.js:1036:11)
at FSEvent.FSWatcher._handle.onchange (fs.js:1406:11)
npm ERR! Test failed. See above for more details.
On the Jest and Facebook GH issues they suggest changing the npm command from
"test": "react-scripts test --env=jsdom",
to
"test": "jest",
which then yields a different error:
npm test ⏎
> [email protected] test /Users/Bazo/Desktop/projekkz/serverlessReact/notes-app-client
> jest
FAIL src/App.test.js
● Test suite failed to run
/Users/Bazo/Desktop/projekkz/serverlessReact/notes-app-client/src/App.test.js: Unexpected token (7:18)
5 | it('renders without crashing', () => {
6 | const div = document.createElement('div');
> 7 | ReactDOM.render(<App />, div);
| ^
8 | ReactDOM.unmountComponentAtNode(div);
9 | });
10 |
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.357s
Ran all test suites.
npm ERR! Test failed. See above for more details.
It seems to be a problem with babel maybe? It has a problem with the JSX caret symbol. When I run a brand new create-react-app and run 'npm test', tests work fine. I'm using latest npm. I've tried deleting node_modules, package.json.lock and reinstalling them, but the problem is still there. Anyone else having this issue? (Great tutorial by the way, I think adding one test at the end to show that tests work would make it stronger).
Oops opened this issue with wrong GH acct sorry