Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #1981
Closed
Open
Issue created Apr 14, 2017 by Administrator@rootContributor

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

  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
Assignee
Assign to
Time tracking