After creating a react app with 'create-react-app' things have been successful till now. I have made a working react project. But now that I'm looking to implement unit testing with jest.
Using npm to install: 'npm install --save-dev jest' Then running: npm ls jest I notice that the react-script is looking for a jest version that is significantly older.
package.json:
"dependencies": {
"react": "^16.8.1",
"react-dom": "^16.8.1",
"react-redux": "^6.0.0",
"react-scripts": "2.1.5",
"redux": "^4.0.1"
},
"devDependencies": {
"jest": "^24.7.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "jest",
"eject": "react-scripts eject"
}
npm ls jest result:
+-- [email protected]
`-- [email protected]
`-- [email protected]
npm start error:
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix
locally.
The react-scripts package provided by Create React App requires a
dependency:
"jest": "23.6.0"
Don't try to install it manually: your package manager does it
automatically.
However, a different version of jest was detected higher up in the tree:
C:\Users\userName\sample js codes\redux\songs\node_modules\jest (version:
24.7.1)
Is there a solution to solve this dependency version issue?
The react-scripts package provided by Create React App requires a dependency: "jest": "23.6.0" Don't try to install it manually: your package manager does it automatically. However, a different version of jest was detected higher up in the tree: C:\Users\userName\sample js codesedux\songs ode_modules\jest (version: 24.7.1)
It is ready to use and ships with Jest! You will only need to add react-test-renderer for rendering snapshots. If you have an existing application you'll need to install a few packages to make everything work well together. We are using the babel-jest package and the react babel preset to transform our code inside of the test environment.
I would expect there to be no version conflicts in official packages which are part of the same official project and that running yarn run start would exit cleanly. Running yarn run start which runs react-scripts start outputs the following error:
$ react-scripts start There might be a problem with the project dependency tree. It is likely not a bug in Create React App, but something you need to fix locally. The react-scripts package provided by Create React App requires a dependency: "babel-jest": "24.7.1" Don't try to install it manually: your package manager does it automatically.
Create-react-app comes with Jest built-in, there is no need to install it additionally.
You have a version conflict now because you installed it additionally. To fix it, revert your changes to package.json.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With