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

Issues in jest tests with expo 52, react 0.76 and new architecture #4561

Open
stefankaetker opened this issue Nov 24, 2024 · 3 comments
Open
Labels

Comments

@stefankaetker
Copy link

Current behaviour

Usage of Icons, e.g. in TextInput left/right lead to issues in jest tests with expo 52 react 0.76 and new architecture enabled.

jest tests break with error: TypeError: loadedNativeFonts.forEach is not a function.
This is completely breaking my build pipeline.

Expected behaviour

npm test

--> all tests pass

How to reproduce?

I have isolated the issue in a small sample app (see https://github.com/stefankaetker/react-native-paper-jest-issue). clone the repo, do rpm install and then npm test.

Preview

What have you tried so far?

Pushing all components to latest version.

Your Environment

software version
ios x
android x
react-native 0.76.3
react-native-paper 5.12.5
node v20.11.1
npm or yarn npm: 10.9.0
expo sdk 52.0.11
@LukaszK88
Copy link

In my case adding jest.mock("expo-font"); to jest.setup resolved it, seems like missing mock to me.

@stefankaetker
Copy link
Author

Thanks, @LukaszK88 that fixed my problem. Would be great to add that to the docs.

@timheilman
Copy link

I found the same issue. Thank you @stefankaetker for making the repro and @LukaszK88 for the suggested workaround.

I've forked @stefankaetker 's reproduction into a still-more-minimized reproduction which does not depend on react-native-paper at all. As such I don't think this issue is with react-native-paper, but rather with the interaction between react-native-testing-library and expo-fonts.

If possible, I would like to check snapshots with the icons actually rendered, so I've filed an issue with react-native-testing-library instead. That may not be the right place, and perhaps expo-font is the right place, but regardless I believe this issue can be closed here.

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

3 participants