Closed
Description
Describe the bug
Getting "React is not defined" when running tests on react-scripts v4.0.1 after ejecting
Steps to reproduce
- Create a new project
- Eject
- 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
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.