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 test fails when trying to mock reanimated

See original GitHub issue

I mock reanimated in my snapshot test as described in the documentation:

jest.mock("react-native-reanimated", () => require("react-native-reanimated/mock"))

But my test fails with the following error:

/[...]/node_modules/react-native-reanimated/mock.js:30
      " __value": number;
                ^

    SyntaxError: Unexpected token :

What am I doing wrong?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jakub-gonetcommented, Feb 17, 2020

This happens because there are TS annotations in .js file. I created #613 which should fix that

0reactions
jakub-gonetcommented, Apr 4, 2020

It should be released on 1.7.1, try checking that

Read more comments on GitHub >

github_iconTop Results From Across the Web

jest will fail with react-native-reanimated · Issue #1589 - GitHub
I created a react-native-library with react-native-reanimated . Now I'm trying to add tests to my project, but all the tests fail.
Read more >
"TypeError" when trying to render react-native-reanimated ...
The problem is with with react-native-reanimated. Follow the procedure as in react-native-reanimated documentation. It should work fine now. If ...
Read more >
Testing with Jest | React Native Reanimated - Software Mansion
Reanimated test mocks use web implementation of Reanimated2. Before you begin using Reanimated mocks you need some setup actions.
Read more >
Testing with Jest - React Navigation
Testing code using React Navigation may require some setup since we need to ... and the NativeAnimatedHelper section for mocking react-native-reanimated
Read more >
React Navigation | React Native Testing Library - Open Source
Make sure that the path to the file in setupFiles is correct. Jest will run these files before running your tests, so it's...
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