I was trying to implement the example shown in Jest website: Getting started with Jest.
While running npm test
on I was getting the following error:
Jest is included with react-scripts. The error is due to a conflict that arose when you installed Jest in a project started with react-scripts. The "Getting started with Jest" guide expects a 'clean' project.
Simply remove Jest from your (dev)dependencies and it should work.
If you want to use Jest for testing React components (which you probably do), you need to modify your test script in package.json
to react-scripts test --env=jsdom
, as it was.