windows 7 create-react-app eject jest fails
Created by: mrLucianoii
Is this a bug report?
Yes
Which terms did you search for in User Guide?
create-react-app eject jest fails windows
Environment
System: OS: Windows 7 Binaries: Node: v8.11.1 Yarn: 1.12.1 npm: 5.6.0 Browsers: npmPackages: react: ^16.6.3 => 16.6.3 react-dom: ^16.6.3 => 16.6.3 react-scripts: 2.1.1 => 2.1.1 npmGlobalPackages:
Steps to Reproduce
(Write your steps here:)
- Create an app on windows --> $ npx create-react-app my-app-test
- Run --> $ yarn test
- Tests work, with no 'Jest encountered an unexpected token'
- Run --> $ yarn eject
- an error is logged upon ejecting
[3/4] Linking dependencies...
{color:red}error {color}An unexpected error occurred: "EPERM: operation not permitted, unlink 'I:\\testing\\my-app\\node_modules\\.cache\\babel-loader'".*
For the above error, I have deleted my npm_modules folder, cleared cache, then reinstalled, and linking dependencies did pass without errors. I'm don't think this is related at this point.
- Terminal logs ejected successfully, however when we now run $ yarn test
Expected Behavior
Yarn test should pass.
Actual Behavior
(master)
$ yarn test
yarn run v1.12.1
$ node scripts/test.js
FAIL C:/Users/user/Scratch/testing/my-app/src/App.test.js
● Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
SyntaxError: C:\Users\usr\Scratch\testing\my-app\src\App.test.js: Unexpected token (7:18)
5 | it('renders without crashing', () => {
6 | const div = document.createElement('div');
> 7 | ReactDOM.render(<App />, div);
| ^
8 | ReactDOM.unmountComponentAtNode(div);
9 | });
10 |
at Parser.raise (node_modules/@babel/parser/lib/index.js:3939:15)
at Parser.unexpected (node_modules/@babel/parser/lib/index.js:5248:16)
at Parser.parseExprAtom (node_modules/@babel/parser/lib/index.js:6328:20)
at Parser.parseExprSubscripts (node_modules/@babel/parser/lib/index.js:5924:21)
at Parser.parseMaybeUnary (node_modules/@babel/parser/lib/index.js:5903:21)
at Parser.parseExprOps (node_modules/@babel/parser/lib/index.js:5812:21)
at Parser.parseMaybeConditional (node_modules/@babel/parser/lib/index.js:5784:21)
at Parser.parseMaybeAssign (node_modules/@babel/parser/lib/index.js:5731:21)
at Parser.parseExprListItem (node_modules/@babel/parser/lib/index.js:7003:18)
at Parser.parseCallExpressionArguments (node_modules/@babel/parser/lib/index.js:6124:22)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 5.011s
Ran all test suites.
Reproducible Demo
I'm using create-react-app right out of the box. It works on my Apple fine, but not on Windows 7.