Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue configuring test with Jest and RN 0.76.3 #4605

Closed
jloracudris opened this issue Jan 16, 2025 · 1 comment
Closed

Issue configuring test with Jest and RN 0.76.3 #4605

jloracudris opened this issue Jan 16, 2025 · 1 comment
Labels

Comments

@jloracudris
Copy link

Current behaviour

Im trying to configure unit test with Jest but the tests are complaining that they dont understand React Native paper elements, so i figured that i had to mock all the components, but trying to create the actual mock has not work as expected. im getting this error

Image

if i remove const originalModule = jest.requireActual("react-native-paper"); and mock them manually they work

Im having a weird error on this file (node_modules/react-native/src/private/animated/NativeAnimatedHelper.js:100:38) and im really lost here tbh

Expected behaviour

being able to configure tests

How to reproduce?

try to mock react native paper in a jest.setup.js file like this

Image

Preview

What have you tried so far?

Your Environment

software version
ios x (doesnt matter)
android x (doesnt matter)
react-native 0.76.3
react-native-paper 5.12.5
node 18.19.1
npm or yarn 10.2.4 (npm)
expo sdk x.x.x (CLI app)
@jloracudris
Copy link
Author

I saw this issue and read it multiple times first: facebook/react-native#47421

then i realized that i needed to update node version to >= 20, also i was using npm then i switched to yarn and this problem wasnt there anymore, so maybe its something related to npm cache or npm itself (which i dont beleive is the case)

TL:DR:

  • Remove package-lock
  • Remove node_modules
  • install with yarn (or clear npm cache)
  • run your tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant