react-native-reanimated icon indicating copy to clipboard operation
react-native-reanimated copied to clipboard

Mock usage and setup not documented

Open johnnywang opened this issue 2 years ago • 4 comments

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: https://github.com/software-mansion/react-native-reanimated/pull/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

  1. Go to https://docs.swmansion.com/react-native-reanimated/docs/guide/testing/
  2. See that there are no references to the aforementioned mock file

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

johnnywang avatar Jan 20 '23 04:01 johnnywang