React-native-reanimated: Jest error when using .interpolate

Created on 17 Feb 2020  路  6Comments  路  Source: software-mansion/react-native-reanimated

I 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

馃Оneed-repro

Most helpful comment

@jakub-gonet

I inspected react-native-reanimated/mock file and recognized one.
There is no interpolate function in exported Value.

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?

image

All 6 comments

Hard to say, could you provide snack with said component and jest test case?

Also running in to this. @thiagoferolla did you find a solution?

@jakub-gonet

I inspected react-native-reanimated/mock file and recognized one.
There is no interpolate function in exported Value.

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?

image

When are you planning to merge this issue? It is getting old, going, and changing this line of code in the node_modules everytime I need to run tests after openning it in vs code.

Holy shit - thanks a lot (@satya164 ). The more you know.

Was this page helpful?
0 / 5 - 0 ratings