I'm getting this error during a test run:
Error: Cannot find module 'react-dom/lib/ReactTestUtils',
I'm also getting this message:
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 installed the required dependencies, I'm still getting the same error.
This only started happening today randomly.
React 15.4 broke some things.
If you downgrade to 15.3, things should continue to work.
I'll look into fixing the underlying issue.
Were on version 14.8, the new react version shouldn't have affected our project.
If you run npm ls, are there no copies of React 15 in your dep tree?
Hmm - I can't reproduce this locally with our tests.
Can you provide your package.json (the deps and dev deps) as well as npm ls output?
I'm not at a liberty to provide, but does node version matter? We're running node0.10, and npm3
@tomoueda can you share the stack trace for the react-dom/lib/ReactTestUtils error?
It seems most likely that you are somehow depending on the latest version of React, or at least of react-addons-test-utils. Your issue coincides with the release timing, and we've seen similar reports with the same error message (https://github.com/facebook/react/issues/8314) reported on the React repo.
Hmm yeah thats probably it, I'll try to find out where I refer to the latest version. Thanks.
@tomoueda also node 0.10 is officially EOL'd, you really need to get on 4 or 6 ASAP.
Thanks,
I figured out my issue:
I had this dependency in my package:
"react-addons-test-utils": "^15.2.0"
this auto upgraded to 15.4, reducing the version of react-addons-test-utils, fixed my problem.
Thanks, everyone.
Also had this issue when I had "react-addons-test-utils": "0.14.0" installed. There was a dependency conflict with the jsx-chai package. Updating to "react-addons-test-utils": "0.14.8" resolved the dependency conflict.
I was on "react-addons-test-utils": "^15.3.2" and I moved to "0.14.8" per a couple of people's suggestion here and it fixed the issue immediately with Travis-CI.
I was having this problem and downgraded to 15.3.0, which solved the problem for now.
Downgraded react-addons-test-utils to ^0.14.8 and fixed the problem!
So what's the solution if I'm on 15.4?
It's not about any particular version, it's that all of the core react-* packages in npm ls must be the same version.
One of my core-react dependencies was set to a different version in the package.json. When I ran npm test - the shell complained that react was not installed. After making sure the core react-* packages were in sync - problem solved. Thanks!
@ljharb what does that means? How to solve this problem? I tried to downgrade react-addons-test-utils still couldn't get my problem solved.
@eldyvoon what's your package.json look like?
I think it is fixed in: [email protected]
Im getting this error. Here is my package.json:
{
"name": "list",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-scripts": "1.0.14"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "tape -r babel-register ./__test__/*.js | tap-spec",
"eject": "react-scripts eject"
},
"devDependencies": {
"babel-preset-es2016": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-register": "^6.26.0",
"extend-tape": "^1.2.0",
"react-addons-test-utils": "^15.6.2",
"tap-spec": "^4.1.1",
"tape": "^4.8.0",
"tape-jsx-equals": "^1.0.0"
},
"babel": {
"presets": ["react", "es2015"]
}
}
@robin22d you have react 16, but react-addons-test-utils 15. Remove the react-addons-test-utils line entirely.
Thank you it works now. Is it build into react 16 now?
@robin22d It's built into the react 16 enzyme adapter (altho neither your package.json nor react-scripts includes enzyme, so i'm not sure how this repo is relevant to you)
For anyone who ran into this thread but is not actually using enzyme. If you find you can't access react-addons-test-utils and you've upgraded from below react (I'm thinking) 15.4 make sure you're importing the TestUtils class from react-dom/test-utils.
react-addons-test-utils no longer exists and has been moved to react-dom. Took me a while to figure out.
The goal with enzyme, however, is not to need the test utils directly at all :-)
@ljharb definitely good to know! For me however I rolled into a (big) project that already uses it and needed to be upgraded to react 16. Searching for a solution to the missing testutils, this came up as the first answer on Google. So I though I'd provide some more information for people following that same route. In any case, thanks for the heads-up!
https://www.zhoulujun.cn/html/tools/webpack/2016_0217_6459.html
"react": "^16.7.0",
"react-addons-test-utils": "^15.6.2",
"react-dom": "^16.7.0",
react-dom 16 根本就没有lib/ReactTestUtils 这玩意儿。
于是修改,react-addons-test-utils index 文件,坑还是未填好
//module.exports = require('react-dom/lib/ReactTestUtils');
module.exports = require('react-dom/test-utils');
最好还是降级到15.x ,期待官方修复!
Most helpful comment
For anyone who ran into this thread but is not actually using enzyme. If you find you can't access
react-addons-test-utilsand you've upgraded from below react (I'm thinking) 15.4 make sure you're importing theTestUtilsclass fromreact-dom/test-utils.react-addons-test-utilsno longer exists and has been moved toreact-dom. Took me a while to figure out.