question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jest error when using .interpolate

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mym0404commented, May 11, 2020

@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

1reaction
Darapsascommented, Jun 2, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found