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 failed after upgrade to react-native 0.64

See original GitHub issue

Describe the bug

Recently I upgraded my project to 0.64 version and faced this issue when I run jest. The same error happened even after I tried with a fresh react-native project with package react-navigation.

type ErrorHandler = (error: mixed, isFatal: boolean) => void;
         ^^^^^^^^^^^^

SyntaxError: Unexpected identifier

  at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14)
  at Object.<anonymous> (node_modules/react-native/jest/setup.js:439:6)

Expected behavior

Jest should be completed without error.

Steps to Reproduce

  1. react-native init
  2. install all the react-navigation packages
  3. set up the testing environment as documented. (https://callstack.github.io/react-native-testing-library/docs/react-navigation#setting-up-the-test-environment)
  4. run jest

Screenshots

Screenshot 2021-03-19 at 8 29 48 PM

Versions

Screenshot 2021-03-19 at 8 30 20 PM

Please help. Thanks in advance 🙏🏿

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

22reactions
thymikeecommented, Mar 19, 2021

Check the path to the file that has unsupported syntax (type keyword), it’s the most important one. It points to a file located inside node_modues/@react-native/. So, you’ll need to add @react-native next to @react-navigation in the transformIgnorePatterns config.

Would you like to contribute a fix to the docs? 😃

transformIgnorePatterns: [
-  'node_modules/(?!(jest-)?react-native|@react-native-community|@react-navigation)',
+  'node_modules/(?!(jest-)?@?react-native|@react-native-community|@react-navigation)',
]
6reactions
McSam94commented, Mar 19, 2021

ahh okay, replaced with jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper'); works 👍🏿

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest failed after upgrade to react-native 0.64 Code Example
Jest failed after upgrade to react-native 0.64 ... node_modules/react-native-gesture-handler/jestSetup.js" ], "moduleFileExtensions": [ "ts" ...
Read more >
Unable to upgrade ReactNative from version 0.59.x to the ...
I am upgrading it to the version, 0.64.2. I run the following command in the project's root directory. npx react-native upgrade.
Read more >
React Native Upgrade Helper
Check out Upgrade Support if you are experiencing issues related to React Native during the upgrading process. Keep in mind that RnDiffApp and...
Read more >
Using TypeScript - React Native
If the above command is failing, you may have an old version of react-native or react-native-cli installed globally on your system. To fix...
Read more >
React Native Testing Library - npm
This is a known issue. It happens because React Native's Jest preset overrides native Promise. Our preset restores it to defaults, which is...
Read more >

github_iconTop Related Medium Post

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