jest fails with @react-native/polyfills/error-guard.js after upgrade to RN 0.64.0 and react 17.0.1

See original GitHub issue

Environment

System: OS: Linux 5.4 Ubuntu 18.04.5 LTS (Bionic Beaver) CPU: (8) x64 Intel® Core™ i7-8550U CPU @ 1.80GHz Memory: 1.29 GB / 15.52 GB Shell: 4.4.20 - /bin/bash Binaries: Node: 14.5.0 - ~/.nvm/versions/node/v14.5.0/bin/node Yarn: 1.22.5 - /usr/bin/yarn npm: 6.14.9 - ~/.nvm/versions/node/v14.5.0/bin/npm Watchman: 20200920.192359.0 - /usr/local/bin/watchman SDKs: Android SDK: API Levels: 19, 24, 25, 27, 28, 29, 30 Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.0 System Images: android-22 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: Not Found Languages: Java: 11.0.10 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.1 => 17.0.1 react-native: 0.64.0 => 0.64.0 npmGlobalPackages: react-native: Not Found

Things I’ve done to figure out my issue

did react-native upgrade which upgraded the appplication

Upgrading version

react-native 0.64.0 react 17.0.1

Description

After the upgrade, I did yarn test but all tests fail with error:

/node_modules/@react-native/polyfills/error-guard.js:14
    type ErrorHandler = (error: mixed, isFatal: boolean) => void;
         ^^^^^^^^^^^^

    SyntaxError: Unexpected identifier

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:78
  • Comments:37

github_iconTop GitHub Comments

57reactions
kumarparth380commented, May 3, 2021

Add @react-native to your transformIgnorePatterns like this to your jest.config.js :

transformIgnorePatterns: [
    "/node_modules/(?!(@react-native|react-native)/).*/"
  ]

Also add the preset something like this in jest.config.js:

preset: "react-native",
setupFilesAfterEnv: ["@testing-library/jest-native/extend-expect"]

Check out for the libraries and update them accordingly to meet latest react version.

39reactions
cinemanjacommented, May 28, 2021

Any updates on this? Still facing the same issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node_modules/react-native/Libraries/polyfills/error-guard.js ...
It worked for me after I changed the .babelrc file to babel.config.js .
Read more >
Testing React Native Apps - Jest
If you are upgrading your react-native application and previously used the jest-react-native preset, remove the dependency from your package.
Read more >
React Native Testing Library - npm
This project is inspired by React Testing Library. Tested to work with Jest, but it should work with other test runners as well....
Read more >
Jest failed after upgrade to react native 064 (8 examples)
How to fix it? jest fails with @react-native/polyfills/error-guard.js after upgrade to RN 0.64.0 and react 17.0.1 #152; Testing React Native Apps ...
Read more >
Test Renderer - React
This package provides a React renderer that can be used to render React components to pure JavaScript objects, without depending on the DOM...
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