Open EvertEt opened 1 month ago
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?
I had this too but just created
// in __mocks__/react-native-reanimated.ts
const useEvent = jest.fn(() => ({}));
export { useEvent }
I fixed this by updating my jest.setup
to use the require('react-native-reanimated').setUpTests();
as per the docs
Old:
jest.mock('react-native-reanimated', () => {
const Reanimated = require('react-native-reanimated/mock');
// The mock for `call` immediately calls the callback which is incorrect
// So we override it with a no-op
Reanimated.default.call = () => {};
return Reanimated;
});
New:
require('react-native-reanimated').setUpTests();
Thank you @SMJ93! This indeed seems to work for most of our tests
For some of our tests, this is introducing a RangeError: Invalid string length
in pretty-format
when using toMatchSnapshot
so for those files we'll need to stick with using react-native-reanimated/mock
.
@SMJ93 Update:
It seems setUpTests
only sets up a custom matcher (toHaveAnimatedStyle
) but not the mocks, see https://github.com/software-mansion/react-native-reanimated/issues/3982
I fixed this by updating my
jest.setup
to use therequire('react-native-reanimated').setUpTests();
as per the docsOld:
jest.mock('react-native-reanimated', () => { const Reanimated = require('react-native-reanimated/mock'); // The mock for `call` immediately calls the callback which is incorrect // So we override it with a no-op Reanimated.default.call = () => {}; return Reanimated; });
New:
require('react-native-reanimated').setUpTests();
Thanks, this solution worked for me ✅.
Description
Steps to reproduce
Looking at the stack trace, I assume we'd need a test with
react-native-gesture-handler
but unable to share our current implementation.Snack or a link to a repository
Not available
Reanimated version
3.6.3
React Native version
0.73.9
Platforms
Android, iOS
JavaScript runtime
Hermes
Workflow
React Native
Architecture
Paper (Old Architecture)
Build type
None
Device
None
Device model
No response
Acknowledgements
Yes