Enzyme with react 17.0.1

Viewed 3803

I'm tryng to install this enzyme adapter for react17 and during the install throw me this error:

$ npm install --save-dev @wojtekmaj/enzyme-adapter-react-17
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: react@17.0.1
npm WARN node_modules/react
npm WARN   peer react@"^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" from mini-create-react-context@0.4.1npm WARN   node_modules/mini-create-react-context
npm WARN     mini-create-react-context@"^0.4.0" from react-router@5.2.0
npm WARN     node_modules/react-router
npm WARN   4 more (react-router, react-router-dom, the root project, @wojtekmaj/enzyme-adapter-react-17)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"0.13.x || 0.14.x || ^15.0.0-0 || ^16.0.0-0" from enzyme-adapter-utils@1.14.0    
npm ERR!   peer react@"^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" from mini-create-react-context@0.4.1npm ERR!   node_modules/mini-create-react-context
npm ERR!     mini-create-react-context@"^0.4.0" from react-router@5.2.0
npm ERR!     node_modules/react-router
npm ERR!       react-router@"5.2.0" from react-router-dom@5.2.0
npm ERR!       node_modules/react-router-dom
npm ERR!         react-router-dom@"^5.2.0" from the root project
npm ERR!   peer react@">=15" from react-router@5.2.0
npm ERR!   node_modules/react-router
npm ERR!     react-router@"5.2.0" from react-router-dom@5.2.0npm ERR!     node_modules/react-router-dom
npm ERR!       react-router-dom@"^5.2.0" from the root project
npm ERR!   3 more (react-router-dom, the root project, @wojtekmaj/enzyme-adapter-react-17)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^0.14 || ^15.0.0 || ^16.0.0-alpha" from airbnb-prop-types@2.16.0
npm ERR! node_modules/enzyme-adapter-utils/node_modules/airbnb-prop-types
npm ERR!   airbnb-prop-types@"^2.16.0" from enzyme-adapter-utils@1.14.0
npm ERR!   node_modules/enzyme-adapter-utils
npm ERR!     enzyme-adapter-utils@"^1.14.0" from @wojtekmaj/enzyme-adapter-react-17@0.4.1
npm ERR!     node_modules/@wojtekmaj/enzyme-adapter-react-17
npm ERR!       dev @wojtekmaj/enzyme-adapter-react-17@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\dittl\AppData\Local\npm-cache\eresolve-report.txt for a full report.

It's this a problem beacause I'm using react 17.0.1? Because in the past I work with the enzyme adapter in react 17 and works perfect.

1 Answers

in the link you sent, the docs say to use the legacy-peer-deps flag.

Note for npm v7 users

enzyme's dependencies have not yet been updated to declare React 17 in peerDependencies. You need to add --legacy-peer-deps to the install command for it to work correctly.

I would suggest using that in your command as such

npm install --save-dev @wojtekmaj/enzyme-adapter-react-17 --legacy-peer-deps
Related