facebook/react

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

vvo opened this issue · 9 comments

vvo commented

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 commented

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

Is it documented somewhere?

vvo commented

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.

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.

Im now experiencing while integrating Mocha + Typescript. :(

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!

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

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?

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.

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