Update documentation for testing dependency with Enzyme
Created by: josephrace
Can you reproduce the problem with latest npm?
Yes
Description
With React 15.5, React Test Utils have moved to react-dom/test-utils
, the react-addons-test-utils
package is deprecated and the shallow renderer has been moved to react-test-renderer/shallow (https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html).
The information in the User Guide should be updated to instruct users to install react-test-renderer
instead of react-addons-test-utils
.
Expected behavior
With freshly bootstrapped app and with enzyme
and react-addons-test-utils
installed as instructed, the following test should pass:
import React from 'react';
import { shallow } from 'enzyme';
import App from './App';
it('renders without crashing', () => {
shallow(<App />);
});
Actual behavior
I see the following warnings in the console:
console.error node_modules/fbjs/lib/warning.js:36
Warning: ReactTestUtils has been moved to react-dom/test-utils. Update references to remove this warning.
console.error node_modules/fbjs/lib/warning.js:36
Warning: Shallow renderer has been moved to react-test-renderer/shallow. Update references to remove this warning.
If I uninstall react-addons-test-utils
then Enzyme shows this warning:
console.error node_modules/enzyme/build/react-compat.js:148
react-dom@15.5+ and react-test-renderer are implicit dependencies when usingreact@15.5+ with enzyme. Please add the appropriate version to yourdevDependencies. See https://github.com/airbnb/enzyme#installation
If I install react-test-renderer
then test passes:
PASS src/App.test.js
✓ renders without crashing (8ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 2.351s
Ran all test suites.
Environment
-
npm ls react-scripts
(if you haven’t ejected): react-scripts@0.9.5 -
node -v
: v6.9.1 -
npm -v
: 4.5.0