Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams /node_modules/@react-native/polyfills/error-guard.js:14 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:469:6)

However, I have already set

transformIgnorePatterns": [
      "node_modules/(?!(jest-)?react-native|react-(native|universal|navigation)-(.*)|@react-native-community/(.*)|@react-navigation/(.*)|bs-platform|(@[a-zA-Z]+/)?(bs|reason|rescript)-(.*)+)"
transformIgnorePatterns": [
      "node_modules"

I have set babel properly like

module.exports = function (api) {
  api.cache(true);
  const presets = ['@babel/preset-env', '@babel/preset-react'];
  const plugins = ['@babel/plugin-proposal-class-properties'];
  return {
    presets,
    plugins,

and I have already tried clearing the cache.

Does anyone have any idea?

Add @react-native to your Jest configuration. Such as:

transformIgnorePatterns : [
      "node_modules/(?!(jest-)?@react-native|react-(native|universal|navigation)-(.*)|@react-native-community/(.*)|@react-navigation/(.*)|bs-platform|(@[a-zA-Z]+/)?(bs|reason|rescript)-(.*)+)"
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.