create-react-app: After upgrade to CRA 2.0, tests run very slow.

Is this a bug report?

I think so.

After upgrade to CRA 2.0 Jest tests run much slower than before. I think it could be made by Jest 23

Did you try recovering your dependencies?

yes, but problem still exists

Which terms did you search for in User Guide?

Running Tests

Environment

Environment: OS: Windows 10 Node: 8.11.2 Yarn: 1.10.1 npm: 6.4.1 Watchman: Not Found Xcode: N/A Android Studio: Not Found

Packages: (wanted => installed) react: ^16.5.2 => 16.5.2 react-dom: ^16.5.2 => 16.5.2 react-scripts: 2.0.3 => 2.0.3

Steps to Reproduce

Tests in previous version reloaded less than 1s. After upgrade to CRA 2.0 tests reload in about 3-4sec. Problec occurs even if I create new empty project

  1. create-react-app app
  2. npm run test

Expected Behavior

It should be faster 😦

Actual Behavior

image

Reproducible Demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 8
  • Comments: 27 (13 by maintainers)

Most upvoted comments

Fresh create-react-app (2.1.1).

 PASS  src/App.test.js
  √ renders without crashing (41ms)

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

Watch Usage: Press w to show more.

So while the test actually seems to run pretty fast (41ms), the setup takes 6 seconds. Re-running doesn’t make it faster.

Windows 10 x64, I7 4690K, SSD…

We also struggle with slow tests if we run: react-scripts-ts test --env=jsdom image

but if we run them with coverage flag they are way faster react-scripts-ts test --env=jsdom --coverage image

I understand that it should be the opposite 😃

We are running: "react": "^16.2.0", "react-dom": "^16.2.0", "react-redux": "^5.0.6", "react-router-dom": "^4.2.2", "react-scripts-ts": "2.17.0", "enzyme-adapter-react-16": "^1.1.1",

Hey, have just tested this now and yes, there is a huge improvement: (running in band) w 2.1.8 Test Suites: 3 skipped, 98 passed, 98 of 101 total Tests: 35 skipped, 379 passed, 414 total Time: 646.448s (running with coverage does bring some improvement but not that much)

w 3.0.0 Test Suites: 3 skipped, 98 passed, 98 of 101 total Tests: 35 skipped, 379 passed, 414 total Time: 139.081s I’ve got some statistics without running in band, but it’s mostly around the same for 3.0.0.

So the bump to 3.0.0 seems to have fixed this issue for windows(windows 10, w node 11.9.0)

@rogeliog Thanks so much 😃 @Timer - Is there opportunity to speed it up? I mean eg. downgrade jest, custom config etc?

Hmmm, might be related to https://github.com/facebook/jest/issues/6694

Maybe we should look into caching module lookups?

I’ve been investigating the issue and created https://github.com/facebook/jest/issues/7110, but I don’t think that is the specific reason for CRA… I’ll keep investigating it.

Did you use the Node test environment previously? We switched the default to JSDOM which has some overhead.