I use React and enzyme library for testing. I migrated to React 16 and trying to run my tests.
Here is my adapter file:
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({ adapter: new Adapter() });
Here is my package.json file:
{
"name": "some-app",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "NODE_ENV=test NODE_PATH=src/ jest --verbose",
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
"precommit": "npm run lint -s"
},
"dependencies": {
"react": "^16.2.0",
"react-datepicker": "0.55.0",
"react-dom": "^16.2.0",
"react-fontawesome": "1.6.1",
"react-google-maps": "8.3.0",
"react-modal": "2.3.2",
"react-paginate": "^5.0.0",
"react-redux": "5.0.6",
"react-router-dom": "4.2.2",
"react-router-redux": "4.0.8",
"react-scripts": "1.0.12",
"react-tabs": "2.0.0",
"react-toastify": "2.1.6",
"recompose": "0.25.0",
"redux": "3.7.2",
"redux-form": "7.0.3",
"redux-thunk": "2.2.0"
},
"devDependencies": {
"babel-cli": "6.26.0",
"babel-plugin-transform-es2015-modules-commonjs": "6.26.0",
"babel-preset-stage-0": "6.24.1",
"enzyme": "^2.9.1",
"enzyme-adapter-react-16": "^1.1.1",
"husky": "0.14.3",
"identity-obj-proxy": "^3.0.0",
"jest": "^22.0.4",
"jest-cli": "^22.0.4",
"jest-css-modules": "1.1.0",
"react-test-renderer": "15.6.1",
"redux-devtools-extension": "2.13.2"
},
"jest": {
"testURL": "http://localhost/",
"transform": {
".*": "<rootDir>/node_modules/jest-css-modules"
},
"setupTestFrameworkScriptFile": "<rootDir>/src/enzyme-setup-file.js",
"moduleNameMapper": {
"\\.(css|less)$": "identity-obj-proxy"
}
}
}
When I try to run npm test, I got an error: react-addons-test-utils is an implicit dependency in order to support [email protected]. Please add the appropriate version to your devDependencies. See https://github.com/airbnb/enzyme#installation.
I tried to set up another version of react-addons-test-utils, but it didn't help. The problem appears when I try to import:
import Enzyme from 'enzyme';
Does anybody know how to solve it?
You are using enzyme version 2.x. To use React16, migrate to enzyme version 3.x.
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