"npm test" does not work with react-scripts@2.0 + react-app-rewired
See original GitHub issuenpm test
throws errors in brand new CRA2.0 app (https://github.com/facebook/create-react-app/issues/3815)
Steps to reproduce
1) Create CRA@2.0 app with react-app-rewired
cd /tmp
npx create-react-app@next --scripts-version=2.0.0-next.66cc7a90 my-react-app
cd my-react-app
npm install
npm install react-app-rewired --save-dev
2) Create a config-overrides.js
file in the root directory
/* config-overrides.js */
module.exports = function override(config, env) {
//do stuff with the webpack config...
return config;
}
3) ‘Flip’ the existing calls to react-scripts
in npm
scripts
/* package.json */
"scripts": {
- "start": "react-scripts start",
+ "start": "react-app-rewired start",
- "build": "react-scripts build",
+ "build": "react-app-rewired build",
- "test": "react-scripts test --env=jsdom",
+ "test": "react-app-rewired test --env=jsdom"
}
4) Run npm test
Expected
test ran successfully
Current behaviour
> my-react-app@0.1.0 test /private/tmp/my-react-app
> react-app-rewired test --env=jsdom
/private/tmp/my-react-app/node_modules/react-scripts/scripts/utils/createJestConfig.js:35
roots: srcRoots.map(toRelRootDir),
^
TypeError: srcRoots.map is not a function
at module.exports (/private/tmp/my-react-app/node_modules/react-scripts/scripts/utils/createJestConfig.js:35:21)
at Object.<anonymous> (/private/tmp/my-react-app/node_modules/react-app-rewired/scripts/test.js:16:16)
at Module._compile (module.js:662:30)
at Object.Module._extensions..js (module.js:673:10)
at Module.load (module.js:575:32)
at tryModuleLoad (module.js:515:12)
at Function.Module._load (module.js:507:3)
at Function.Module.runMain (module.js:703:10)
at startup (bootstrap_node.js:193:16)
at bootstrap_node.js:660:3
npm ERR! Test failed. See above for more details.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:11 (3 by maintainers)
Top Results From Across the Web
react-app-rewired - npm
It is not able to configure compilation in test mode because test mode does not get run through Webpack at all (it runs...
Read more >85 - Stack Overflow
I encountered this problem after I did an npm update. These packages were installed: "react-leaflet": "^3.2.0".
Read more >How To Set Up a React Project with Create React App
Node.js version 10.16.0 installed on your computer. To install this on macOS ... Like npm test , this script does not need the...
Read more >react-app-rewired-esbuild - npm package - Snyk
The npm package react-app-rewired-esbuild was scanned for known vulnerabilities and missing license, and no issues were found. Thus the package was deemed as ......
Read more >How to polyfill node core modules in webpack 5 - Alchemy
Because the current version of webpack no longer includes NodeJS polyfills by default, it is causing issues for developers that use create-react ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I tried installing react-app-rewired
^1.6.2
and react-scripts2.0.0-next.a671462c
, then manually performing the update found in #243, and everything seems to work fine@Guria FYI webpack 4
https://github.com/facebook/create-react-app/commit/d1454febd13c8e008e5dec4f13e7d55bf4eb4d18
https://twitter.com/dan_abramov/status/998258353255088128