Jest Web Test Run Initialization is Slow O(10x) Slower than it Should Be
See original GitHub issueProblem When running jest tests the runtime seems to be 12-14 seconds just to spin up a test and mount a component. The actual tests are fast. That implies 99% of the wall time is due to setup – possibly because we have several chained yarn calls but most likely due to source maps (usual suspect for this).
As evidence, API tests are MUCH faster.
PASS api api/src/services/stages/stages.test.ts
stages
✓ returns all stages (45 ms)
✓ returns a single stage (19 ms)
✓ creates a stage (16 ms)
✓ updates a stage (14 ms)
✓ deletes a stage (12 ms)
Test Suites: 1 passed, 1 total
Tests: 5 passed, 5 total
Snapshots: 0 total
Time: 1.043 s
FAIL web web/src/layouts/DefaultLayout/DefaultLayout.test.tsx (13.13 s)
DefaultLayout
✓ defaults to open (260 ms)
✓ opens on menu click (88 ms)
✓ closes on chevron click (58 ms)
✕ should navigate to '/home' (47 ms)
✓ renders successfully (33 ms)
Resolution We should probably add an option to ignore source maps / use an ugly version by default and then use a full fidelity one when useing a debugger launch config – something like that.
I have a PR cooking that adds the debugging config for jest in vscode. I may be able to address this as well with a bit of advice on where to stick an option – perhaps just as an ENV variable.
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:9 (7 by maintainers)
Top Results From Across the Web
javascript - Jest - Simple tests are slow - Stack Overflow
I would be curious to see how long the tests take if you add another simple "should be fast 2" test. If the...
Read more >How to make your sluggish Jest tests go faster - ITNEXT
A step-by-step guide how to improve performance of your slow Jest unit test and make them blazingly fast and delightful again.
Read more >Effective Python Testing With Pytest
In this tutorial, you'll learn how to take your testing to the next level with pytest. You'll cover intermediate and advanced pytest ...
Read more >Slow rendering - Android Developers
Try running your app on a slower device to exacerbate the problem. ... detect slow render times and run the tests frequently to...
Read more >Component testing scenarios - Angular
You must tell the TestBed to perform data binding by calling fixture. ... However, if you run the tests in a non-CLI environment,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Let me take a poke at it.
Should get to it this week