Jest fail Unable to find "react / lib / React" module with "ReactShallowRenderer.js" after updating React 16

Just updated to react v16.0.0 to v.15.6.2 (via rebase)

Problem

Running jests tests gives the following error:

  ● Test suite failed to run

    Cannot find module 'react/lib/React' from 'ReactShallowRenderer.js'

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:191:17)
      at Object.<anonymous> (node_modules/react-test-renderer/lib/shallow/ReactShallowRenderer.js:16:13)

How i updated

Step 1: .lock yarn

During rebase on a branch with React v16 - I let yarn 1.1.0 take care of merge conflicts on my yarn.lock file

Step 2: add an adapter

I added a new adapter setup for TestFramework.js

import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });

Step 3: Service Packs

And updated the following packages:

react "16.0.0",
enzyme "3.1.0",
jest "21.2.1",
babel-jest "21.2.0",

Can anyone see anything that I missed?

+4
source share
1 answer

React 16, v16.x.x of react-test-renderer.

+8

Source: https://habr.com/ru/post/1687317/


All Articles