Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-addons-test-utils 15.4.0 now depends on react-dom instead of react #8314

Closed
vvo opened this issue Nov 16, 2016 · 9 comments
Closed

react-addons-test-utils 15.4.0 now depends on react-dom instead of react #8314

vvo opened this issue Nov 16, 2016 · 9 comments

Comments

@vvo
Copy link

vvo commented Nov 16, 2016

Do you want to request a feature or report a bug?
Report a bug

What is the current behavior?
react-addons-test-utils 15.4.0 has a peer dependency on react-dom and uses it, 15.3.0 had a peer dependency on react.

In 15.3.0, react-addons-test-utils/index.js:

module.exports = require('react/lib/ReactTestUtils');

In 15.4.0, react-addons-test-utils/index.js:

module.exports = require('react-dom/lib/ReactTestUtils');

If your code contains:

import {isElement} from 'react-addons-test-utils';

It will fail given your current dependencies.

So if you did not have react-dom in your dependencies, because previously it was not needed, now it is and it will break your code.

Is this a breaking change?

This leads to errors like:

Module not found: Error: Can't resolve 'react-dom/lib/ReactTestUtils' or Cannot find module 'react-dom/lib/ReactTestUtils'

Current workaround

npm install react-dom --save[-dev]
@matm
Copy link

matm commented Nov 17, 2016

Seriously, that's a breaking change that can take CI systems down.

Is it documented somewhere?

@vvo
Copy link
Author

vvo commented Nov 17, 2016

I think we have all various experiences with this bug, let's keep it constructive and see if we can do something about it so that we focus on positive not negative comments.

@gaearon
Copy link
Collaborator

gaearon commented Nov 17, 2016

That's indeed frustrating but this ship has sailed now. Sorry we screwed it up.

We released 15.4.0 RC a month ago and publicly asked for feedback:

Unfortunately nobody reported this issue even as it was discovered in algolia/react-element-to-jsx-string#56 before the stable release.

Sorry for breaking your CIs, hopefully the fix wasn't too complex.

@junibrosas
Copy link

Im now experiencing while integrating Mocha + Typescript. :(

@gaearon
Copy link
Collaborator

gaearon commented Nov 18, 2016

All you need to do is to add the dependency on react-dom. Unless you have some new information about this issue I think further “me too” comments won’t be helpful. Again, sorry about this!

@chaintng
Copy link

chaintng commented Nov 18, 2016

A work around to make CI work,
make sure that your app contains follow dependencies all in the same version in package.json

  • react-addons-test-utils
  • react
  • react-dom

@axelson
Copy link

axelson commented Dec 2, 2016

I got bit by react-addons-test-utils 15.4.1 not being compatible with react 15.2.1. Makes me wish that npm shrinkwrapped dev dependencies as well (which up until now I assumed it did). Is backwards compatibility of major versions a goal for react-addons-test-utils?

@gaearon
Copy link
Collaborator

gaearon commented Dec 3, 2016

React does not currently support using different versions of its packages in one project. We are working to decouple them to the point it is possible but this will take us a while.

@zhoulujun
Copy link

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 ,期待官方修复!

dragonworr added a commit to dragonworr/vortigern that referenced this issue Jun 16, 2023
Module react-addons-test-utils and react-dom should use same
version, otherwise test would fail to start.
Ref: facebook/react#8314
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants