Skip to content

Error on tests when Enzyme is added #3206

@pedro-stanaka

Description

@pedro-stanaka

Is this a bug report?

Yes

Can you also reproduce the problem with npm 4.x?

Yes;

Which terms did you search for in User Guide?

I searched about testing, about enzyme and on the troubleshooting page as well.

Environment

  1. node -v: v6.11.3
  2. npm -v: 4.6.1
  3. yarn --version (if you use Yarn): 1.1.0
  4. npm ls react-scripts (if you haven’t ejected): [email protected]

Then, specify:

  1. Operating system: Windows

Steps to Reproduce

  1. npm install -g create-react-app
  2. create-react-app test-jest-enzyme
  3. cd test-jest-enzyme
  4. Change file src/App.test.js to be:
import React from 'react';
import App from './App';
import {shallow} from "enzyme";

it('renders without crashing', () => {
    shallow(<App />);
});
  1. npm test

Expected Behavior

The tests would pass and no exception would be thrown.

Actual Behavior

Will give:

          Enzyme Internal Error: Enzyme expects an adapter to be configured, but found none. To
          configure an adapter, you should call `Enzyme.configure({ adapter: new Adapter() })`
          before using any of Enzyme's top level APIs, where `Adapter` is the adapter
          corresponding to the library currently being tested. For example:

          import Adapter from 'enzyme-adapter-react-15';

          To find out more about this, see http://airbnb.io/enzyme/docs/installation/index.html


      at validateAdapter (node_modules/enzyme/build/validateAdapter.js:14:11)
      at Object.<anonymous>.it (src/App.test.js:6:25)

Reproducible Demo

https://gitlab.com/DevLearn/jest-react-broken

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions