toHaveAnimatedStyle
method throws a typescript error when expect
is imported from @jest/globals
#6848
Labels
Missing info
The user didn't precise the problem enough
Missing repro
This issue need minimum repro scenario
Platform: iOS
This issue is specific to iOS
Description
The
toHaveAnimatedStyle
method on the jestexpect
object throws aProperty 'toHaveAnimatedStyle' does not exist on type ...
error when importingexpect
from@jest/globals
. The error is only a typescript error as the test still runs without any issues and passes as expected.This happens because
node_modules/react-native-reanimated/lib/typescript/jestUtils.d.ts
does not extend the@jest/globals
expect matchers. For an example of how this can be done, check out this file from the react testing library.I fixed this by adding a
react-native-reanimated.d.ts
file to my project with the following contents:Adding something similar to reanimated should automatically fix the issue.
Steps to reproduce
expect(<a component>).toHaveAnimatedStyle(<a style>)
in a test. You should see the typescript error.Snack or a link to a repository
Reanimated version
3.16.6
React Native version
0.76.1
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: