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.

Jest Web Test Run Initialization is Slow O(10x) Slower than it Should Be

See original GitHub issue

Problem 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:open
  • Created a year ago
  • Reactions:4
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
MichaelrMentelecommented, Apr 22, 2022

Let me take a poke at it.

1reaction
MichaelrMentelecommented, May 3, 2022

Should get to it this week

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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