question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Very poor performance on basic tests

See original GitHub issue

🐛 Bug Report

I’ve created a simple test with no configuration. You can find it here. It takes 7.6 seconds just to start jest, and then, on file change, it takes 5 seconds to re-run. There’s clearly something wrong here.

Mocha and Chai, for example, start in around 4 seconds, but afterward, the re-run is almost instant.

It’s weird that Jest reports that the test takes 14ms but shows me the result in 5 seconds.

image

On top of this, if you add more basic tests, the time just seems to go up.

image

To Reproduce

Clone my minimal repository, yarn install and yarn test.

Expected behavior

It should be faster than this.

Link to repl or repo (highly encouraged)

https://github.com/cozmy/jest-performance

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: Windows 10
    CPU: (8) x64 Intel(R) Core(TM) i7-4700MQ CPU @ 2.40GHz
  Binaries:
    Node: 8.12.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.13.0 - C:\Users\CosminCristian\AppData\Roaming\npm\yarn.CMD
    npm: 6.8.0 - C:\Program Files\nodejs\npm.CMD

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:196
  • Comments:83 (6 by maintainers)

github_iconTop GitHub Comments

33reactions
pelotomcommented, Jul 24, 2020

The main startup delay seems to come from require()-ing all the dependencies.

time-require reports around 10 seconds worth of require() calls on my current system.

Main culprits, according to that tool are:

  • babel - this might just be specific to my setup (@babel/preset-env takes 3.6 seconds)
  • jsdom - 1.2 seconds in isolation
  • sane - 0.5 seconds in isolation, most of which is caused by micromatch 3.

For JSDOM, there is already some work for cutting down dependencies and thus improving load times. They also have an active issue regarding request, which takes my machine .25 seconds to load.

An actionable item for the jest team might be replacing sane.

This right here is the issue ☝️

I really, really wish Jest would provide an option not to reload the entire module tree on every single test suite. We write our code in a mostly pure style and do not use mutable global state so it is a complete waste for us to be reloading modules every time. And it is a huge waste: a typical test suite in our code base takes 16 seconds to run, and < 1 second of that is running the actual test!

32reactions
nicewaytodoitcommented, Mar 18, 2021

2 years have gone since I created this issue https://github.com/facebook/jest/issues/7619 I believe the only way to fix this is just to use Mocha/Chai/Jasmine… or anything else but Jest! 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

Students performed poorly on an exam - Eberly Center
Students performed poorly on an exam. Exam was not aligned with instructional activities. Exam questions or instructions are ambiguous or confusing. Students ...
Read more >
Some students perform poorly on tests for reasons other than ...
Some students perform poorly on tests for reasons other than lack of preparation or poor study skills. This common problem is called test...
Read more >
6 Reasons Your Child Does Poorly On Tests | Scholars Canada
Poor organization and time management skills often mean your child isn't studying effectively before a test, leading to poor grades. In many ...
Read more >
Simple Strategies for Improving Test Performance
Good reviewing is no substitute for poor studying. Don't expect to start studying one week prior to a test and perform well. The...
Read more >
My performance in a test I studied hard for is very poor ... - Quora
Slaving away in front of a computer screen or books for hours on end · Taking notes over and over again · Cramming...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found