Jest error when using .interpolate
See original GitHub issueI wrote an animation using timing and interpolate but when testing the component with Jest it fails with the error buttonAnimationState.interpolate is not a function
even though I’m using the official mock from react-native-reanimated.
jest.mock("react-native-reanimated", () => require("react-native-reanimated/mock"))
Checking the mock provided, I found an .interpolate
definition so I don’t know what’s happening. Maybe it’s missing in the new Animated.Value()
mock
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top Results From Across the Web
"TypeError" when trying to render react-native-reanimated ...
I have this in a /spec_config/jest.js file, that is loaded (along with a few other global mocks) with the following line in my ......
Read more >Jest 27, each() tests with variable interpolation - YouTrack
Jest 27, each() tests with variable interpolation: tests not represented in UI when running individual tests : WEB-51316.
Read more >Testing Asynchronous Code - Jest
test('the fetch fails with an error', async () => { expect.assertions(1); try { await fetchData(); } catch (e) { expect(e).toMatch('error'); }
Read more >eslint-plugin-jest - npm
Start using eslint-plugin-jest in your project by running `npm i ... "jest/no-identical-title": "error", "jest/prefer-to-have-length": ...
Read more >Reduce boilerplate test code with Jest it.each | by E.Y. - Medium
Recently I have found a nice trick when use Jest with React — it.each . ... it passes in a table using string...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jakub-gonet
I inspected
react-native-reanimated/mock
file and recognized one. There is no interpolate function in exportedValue
.Quick fix : Add interpolate in Value constructor function
This resolved my case. But it seems to need PR for this.
I am using
typescript
. Is is related to this issue?Holy shit - thanks a lot (@satya164 ). The more you know.