简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM