-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Mock usage and setup not documented #3982
Comments
Hey! 👋 The issue doesn't seem to contain a minimal reproduction. Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem? |
@kacperkapusciak It's an old PR and our docs have change a lot since that time. Do you think we should improve it to inform about mocks better, or can we close this PR? |
@Latropos I think it's a valid problem that we haven't addressed. Let's keep it open |
for anyone else who might run into issues with jest tests where it says for example, jest.mock("react-native-reanimated", () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires, no-undef
const AnimatedMock = require("react-native-reanimated/mock")
return {
...AnimatedMock,
ZoomIn: {
duration: jest.fn(),
},
ZoomOut: {
duration: jest.fn(),
},
}
}) If your issue isn't |
Description
It's not clear from the documentation whether mocking is necessary when trying to test reanimated code in Jest/RNTL, i.e.
jest.mock('react-native-reanimated', () => require('react-native-reanimated/mock'));
I see that there was an old issue/PR opened up against this a few years ago, at which point there WERE instructions added to the readme to reference the included mock file: #410. There are also multiple references in various (old) threads about how this was necessary, but nothing recent.It seems like this was dropped at some point, and is not mentioned on the testing page either: https://docs.swmansion.com/react-native-reanimated/docs/guide/testing/
I've been struggling to get RNTL tests around gesture handler + reanimated to work, and it's not obvious to me if I need to mock out reanimated (in which case I simply can't test code using things like
useAnimatedGestureHandler
since it's mocked out) or not (which seems to cause other failures / tests to not complete)Steps to reproduce
Snack or a link to a repository
https://docs.swmansion.com/react-native-reanimated/docs/guide/testing/
Reanimated version
2.12.0
React Native version
0.70.5
Platforms
iOS
JavaScript runtime
None
Workflow
None
Architecture
None
Build type
None
Device
None
Device model
No response
Acknowledgements
Yes
The text was updated successfully, but these errors were encountered: