Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jest fails to compile flow (react-native) #11723

Closed
MrPupik opened this issue Aug 3, 2021 · 1 comment · May be fixed by joseroubert08/jest#122
Closed

jest fails to compile flow (react-native) #11723

MrPupik opened this issue Aug 3, 2021 · 1 comment · May be fixed by joseroubert08/jest#122

Comments

@MrPupik
Copy link

MrPupik commented Aug 3, 2021

🐛 Bug Report

Cannot get jest to run on my react-native project.

When trying to set up jest on react-native project, the following error occurred:

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

    SyntaxError: Unexpected identifier

      at Runtime._execModule (node_modules/jest-runtime/build/index.js:1157:58)
      at Object.<anonymous> (node_modules/react-native/jest/setup.js:16:6)

It appears my jest runs react-native's jest/setup.js. and can't compile it's dependancy because of 'type' (flow keyword).

To Reproduce

Steps to reproduce the behavior:
I'm using jest-expo (version 42.0.1) with babel-jest, and added babel-plugin-transform-flow-strip-types as described here

my jest configuration in package.json:


     "jest": {
    "preset": "jest-expo",
    "setupFilesAfterEnv": [
      "@testing-library/jest-native/extend-expect"
    ],
    "moduleNameMapper": {
      "@react-native-firebase/analytics$": "<rootDir>/__mocks__/@react-native-firebase/analytics.js"
    },
    "transformIgnorePatterns": [
      "rootDir>/node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|@sentry/.*)",
      "<rootDir>/node_modules/(?!expo-image-manipulator|@react-native|@react-native-firebase/analytics|@unimodules/)",
      "<rootDir>/node_modules/(?!expo-facebook)"
    ],
    "collectCoverage": false,
    "setupFiles": [
      "./jestSetup.js"
    ],
    "collectCoverageFrom": [
      "**/*.{js,jsx}",
      "!**/coverage/**",
      "!**/node_modules/**",
      "!**/babel.config.js",
      "!**/jest.setup.js"
    ]
  }

my babel.config.js:


    module.exports = function (api) {
       api.cache(true);
       return {
       presets: ["babel-preset-expo"],
       plugins: ["@babel/plugin-transform-flow-strip-types"],
       };
    };

envinfo

System:
    OS: Windows 10 10.0.19042
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
  Binaries:
    Node: 14.15.1 - C:\Program Files\nodejs\node.EXE     
    npm: 7.0.14 - C:\Program Files\nodejs\npm.CMD        
@github-actions
Copy link

github-actions bot commented Sep 3, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant