Running test immediately after npm create-react-app is extremely slow
Asked Answered
S

1

11

Immediately after npx create-react-app my-app, I move into the my-app folder and do CI=true npm test.

The resulting output is:

> react-scripts test

PASS src/App.test.js
  ✓ renders learn react link (39ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        4.465s
Ran all test suites.

In package.json after adding the flag --env=jsdom to react-scripts test, I got:

PASS src/App.test.js
  ✓ renders learn react link (42ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        2.026s, estimated 3s
Ran all test suites.

My expectation is that everything would run in less than 1 second. Can I get it to run faster than shown above if I'm rendering react components in the tests?

Running with yarn doesn't make a difference.

Separatist answered 13/5, 2020 at 19:39 Comment(1)
Hopefully Vite will make this faster once they have first class Jest support.Yettie
D
0

Run it in gitpod... it's a containerized electron app for vscode that runs in the browser and is blisteringly fast compared to running npm commands on a local machine and is noticably faster than github code spaces as well.

If that's not to your liking than you could probably run npm audit fix -f and Or


npm cache clear --force
npm cache rm --force
npm cache verify 

You cous also append the test.skip to save time on test's you're not currently working on...

In my experience slowdowns are usually the result of some dependency weirdness or your computer overheating after a long day of indifference to the cpu's temperature.

Devisable answered 6/8, 2022 at 9:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.