Just upgraded to react v16.0.0 from v15.6.2 (via a rebase)
Problem
Running my 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 upgraded
Step 1: yarn.lock
During the rebase, onto a branch with React v16 - I let yarn 1.1.0 take care of merge conflicts on my yarn.lock file
Step 2: Add adapter
I added the new adapter setupTestFramework.js
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });
Step 3: upgrade packages
And upgraded the following packages:
react "16.0.0",
enzyme "3.1.0",
jest "21.2.1",
babel-jest "21.2.0",
Can anyone see anything I missed?
When used with React 16, Enzyme requires v16.x.x
of react-test-renderer
to be installed.
Worked for me by following below comand
npm uninstall react-dom
and then
npm install react-dom --save-dev
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With