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

New jsx transform not applied when running tests after ejecting #10184

Closed
celerytea opened this issue Dec 3, 2020 · 1 comment
Closed

New jsx transform not applied when running tests after ejecting #10184

celerytea opened this issue Dec 3, 2020 · 1 comment

Comments

@celerytea
Copy link

Describe the bug

Getting "React is not defined" when running tests on react-scripts v4.0.1 after ejecting

Steps to reproduce

  1. Create a new project
  2. Eject
  3. Run a test

Actually I also got #6174 so I needed to remove node_modules and rerun yarn, but this is a different issue.

Analysis

Looking at

'^.+\\.(js|jsx|mjs|cjs|ts|tsx)$': isEjecting
? '<rootDir>/node_modules/babel-jest'
: resolve('config/jest/babelTransform.js'),

the unejected version runs babelTransform.js while the ejected version runs babel-jest directly, however babelTransform.js is where we set up the new jsx runtime.

Copying babelTransform.js and updating the "transform" key in package.json fixed this issue.

Alternatively updating package.json from

"babel": {
  "presets": [
    "react-app"
  ]
}

to

"babel": {
  "presets": [
    [
      "react-app",
      {
        "runtime": "automatic"
      }
    ]
  ]
}

would also fix this issue.

@maxsbelt
Copy link
Contributor

maxsbelt commented Dec 7, 2020

Should be fixed by #10091.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants