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

Update documentation for testing dependency with Enzyme #1981

Closed
josephrace opened this issue Apr 14, 2017 · 0 comments
Closed

Update documentation for testing dependency with Enzyme #1981

josephrace opened this issue Apr 14, 2017 · 0 comments

Comments

@josephrace
Copy link
Contributor

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

  1. npm ls react-scripts (if you haven’t ejected): react-scripts@0.9.5
  2. node -v: v6.9.1
  3. npm -v: 4.5.0
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant