Skip to content

Update documentation for testing dependency with Enzyme #1981

Closed
@josephrace

Description

@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
    [email protected]+ and react-test-renderer are implicit dependencies when [email protected]+ 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

  1. npm ls react-scripts (if you haven’t ejected): [email protected]
  2. node -v: v6.9.1
  3. npm -v: 4.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions