windows 7 create-react-app eject jest fails
See original GitHub issueIs 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.
Issue Analytics
- State:
- Created 5 years ago
- Comments:21 (4 by maintainers)
Top Results From Across the Web
Configuration of jest in react application which is ejected from ...
Unable to run test after eject from create react app. Step1 : Ejected Create react app. Step2 : In package.json we are using...
Read more >Create React App
Whether you're using React or another library, Create React App lets you focus on code, not build tools. To create a project called...
Read more >Everything you need to know about react-scripts
Create React App uses Jest as a test runner. The test script enables you to launch the test runner in interactive watch mode...
Read more >eslint-config-react-app - npm
ESLint configuration used by Create React App. Latest version: 7.0.1, last published: 9 months ago. Start using eslint-config-react-app in ...
Read more >Error when using create-react-app in node.js on Windows 7 ...
syscall: 'unlink', npm ERR! path: 'C:\\Users\\Desktop\\my-react-app\\node_modules\\nan\\pac kage.json' } npm ERR! npm ERR! Please try running ...
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 FreeTop 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
Top GitHub Comments
@mrmckeb Yes, I’m able to confirm these differences. I’ve tested the ejection process on multiple computers running W7 (here at the office), where in one case we ejected a cra living on our machines master drive and it produce no errors. Then I created a cra living on a slave drive, on the same test computers and was able to reproduce the issue.
@mrmckeb I’ll work on a solution for this issue and will raise a PR 😃