Unable to update cleanly to Expo 44
Describe the bug
npm i --save-dev @testing-library/react-native@latest react-test-renderer@latest
Should update the dependencies to the current version using npm which has stricter peer version resolution than yarn, but it is failing.
❯ npm i --save-dev @testing-library/react-native@latest react-test-renderer@latest
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: @devhaus/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR! dev react@"17.0.1" from the root project
npm ERR! peer react@">=16.0.0" from @testing-library/[email protected]
npm ERR! node_modules/@testing-library/react-native
npm ERR! dev @testing-library/react-native@"9.0.0" from the root project
npm ERR! 1 more (react-native)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.2" from [email protected]
npm ERR! node_modules/react-test-renderer
npm ERR! dev react-test-renderer@"17.0.2" from the root project
npm ERR! peer react-test-renderer@">=16.0.0" from @testing-library/[email protected]
npm ERR! node_modules/@testing-library/react-native
npm ERR! dev @testing-library/react-native@"9.0.0" 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\trajano\AppData\Local\npm-cache\eresolve-report.txt for a full report.
Expected behavior
Should work, but didn't I had to do
npm i --save-dev --legacy-peer-deps @testing-library/react-native@latest react-test-renderer@latest
Steps to Reproduce
From an Expo 44 project
npm i --save-dev @testing-library/react-native@latest react-test-renderer@latest
Screenshots
Versions
This is after I ran the --legacy-peer-deps
❯ npx envinfo --npmPackages react,react-native,react-test-renderer,@testing-library/react-native
npmPackages:
@testing-library/react-native: ^9.0.0 => 9.0.0
react: 17.0.1 => 17.0.1
react-native: 0.64.3 => 0.64.3
react-test-renderer: ^17.0.2 => 17.0.2
@trajano this doesn't work because react 17.0.2 is a peer dep of react-test-renderer 17.0.2. You can either use version 17.0.1 of react-test-renderer or bump your react version to 17.0.1
Tried to do this again after clearing node_modules and package-lock.json Still no luck but the error is a bit closer now.
❯ npm i @testing-library/react-native@"^9.1.0" react-test-renderer@"^17.0.1" [email protected]
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR! react@"17.0.1" from the root project
npm ERR! peer react@">=16.0.0" from @testing-library/[email protected]
npm ERR! node_modules/@testing-library/react-native
npm ERR! dev @testing-library/react-native@"^9.1.0" from the root project
npm ERR! 1 more (react-native)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.2" from [email protected]
npm ERR! node_modules/react-test-renderer
npm ERR! dev react-test-renderer@"^17.0.1" from the root project
npm ERR! peer react-test-renderer@">=16.0.0" from @testing-library/[email protected]
npm ERR! node_modules/@testing-library/react-native
npm ERR! dev @testing-library/react-native@"^9.1.0" 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\trajano\AppData\Local\npm-cache\eresolve-report.txt for a full report.
It looks like there's a hard dependency to React test renderer 16 on [email protected]
@trajano the error seems to be the same, it tries to resolve the react 17.0.2 peer dependency from react-test-renderer 17.0.2, I think it is because you're installing react-test-renderer@"^17.0.1", which resolves to the version 17.0.2, maybe you can try installing [email protected] instead
I think it's because I put react-test-renderer@"^17.0.1" it seems to install cleanly on [email protected] I am going to try again in a bit because I had to revert the code back again due to another dependency.
UPDATE: I tried still failed so I was looking at it, it appears my TLRN library is set to 7.2.0 upgrading to @latest failed due to test renderer. Was just about to check if your package.json dependency can resolve it cleanly
for now
npm uninstall react-test-renderer
npm i @testing-library/react-native@latest [[failed]]
It seems that it is looking for the latest react. So I think it needs to be manually set. This works
npm i @testing-library/react-native@latest [email protected]
So I am thinking that the expo-cli needs some form of intelligence for react-test-renderer so it keeps it in sync with react.
https://expo.canny.io/feature-requests/p/react-test-renderer-should-be-updated-by-expo-upgrade
Closing as this is a bug in Expo
I've added the root cause/fix for this issue to our Troubleshooting guide: https://callstack.github.io/react-native-testing-library/docs/troubleshooting#matching-react-native-react--react-test-renderer-versions
I can't find anywhere if the library works with Expo 46 or 47 (React 18). It does not install in any way I tried so far.
We have an example app which is configured using Expo 47 (previously was also using 46). @bogadrian you might use that as a reference on how to properly set it up with Expo.
Thank you very much for the reply.
On Tue, 6 Dec 2022 at 00:06, Maciej Jastrzebski @.***> wrote:
We have an example app https://github.com/callstack/react-native-testing-library/tree/main/examples/basic which is configured using Expo 47 (previously was also using 46). @bogadrian https://github.com/bogadrian you might use that as a reference on how to properly set it up with Expo.
— Reply to this email directly, view it on GitHub https://github.com/callstack/react-native-testing-library/issues/938#issuecomment-1338305150, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK4ZZDAMKZUOVBERKA33RXDWLZYQPANCNFSM5ROYPSZA . You are receiving this because you were mentioned.Message ID: @.***>
-- Bogdan Adrian