create-react-app: windows 7 create-react-app eject jest fails

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:)

  1. Create an app on windows --> $ npx create-react-app my-app-test
  2. Run --> $ yarn test
  3. Tests work, with no ‘Jest encountered an unexpected token’
  4. Run --> $ yarn eject
  5. 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.

  1. 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.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 21 (4 by maintainers)

Most upvoted 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 😃