Skip to content

Make yarn test-cli and yarn test-all faster - #6369

Open
canova wants to merge 4 commits into
firefox-devtools:mainfrom
canova:optimize-cli-tests
Open

canova wants to merge 4 commits into
firefox-devtools:mainfrom
canova:optimize-cli-tests

Conversation

@canova

@canova canova commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Main | Deploy preview

Fixes #6368.

yarn test-all took about 24.5s locally, and most of that was the profiler-cli tests. They only started after every other task had finished, and basic.test.ts took 18-19s on its own because its 39 tests each start a daemon and run one after another.

This PR brings test-all down to ~7.8s from ~24.5s locally:

  • Run test-cli in parallel during test-all instead of after it
  • Load the profile once in marker-info.test.ts, since all of its tests only read from the session (that file went from 11.7s -> 2s).
  • Split basic.test.ts into basic, profile-save, filters, limits and strategy so Jest can run them in parallel. The test bodies are unchanged. The basic.test.ts file was the longest running file in CLI tests.
  • In the still-starting samply test, wait for the samply pid file instead of relying on a 2s load timeout, which lets the timeout drop to 100ms (this test went from ~2.3s -> ~0.35s).

We could probably shave the CLI tests down further, but it wouldn't buy us much. yarn test alone takes about 6s and runs alongside them, so it's the limit now. yarn test-cli also takes about 6s alone locally now.

One important thing is that now the CLI tests run in parallel with the yarn test. I don't remember why we made it that way initially, but I couldn't find any reason to do now. So I think it's fine, but we might want to keep that in mind in case something breaks.

@canova
canova requested a review from mstange October 1, 2026 10:53
@canova
canova requested a review from fatadel as a code owner October 1, 2026 10:53
@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.12%. Comparing base (db4374d) to head (f58f2fe).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #6369    +/-   ##
========================================
  Coverage   84.12%   84.12%            
========================================
  Files         356      356            
  Lines       38445    38445            
  Branches    10888    10787   -101     
========================================
  Hits        32340    32340            
  Misses       5676     5676            
  Partials      429      429            

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

canova added 4 commits October 1, 2026 13:12
They used to start only after everything else had finished, even though
they are the slowest task. Starting them first lets them overlap with
the browser tests and the linters.
These tests only read from the session, so reloading the profile and
listing the markers before each of them was wasted work. This takes the
file from about 11.7s to 2s.
basic.test.ts had grown to 39 tests that each start a daemon, and since
Jest only parallelizes across files, it took about 18s on its own and
was the longest task in test-all. The save, filter, limit and strategy
tests now live in their own files, so the longest file takes about 5s.
…tarting test

The test read samply's pid file right after the client gave up, so the
load timeout had to be long enough for the fake samply to start, and the
test spent 2s doing nothing. Waiting for the pid file removes that race,
so the timeout only needs to be long enough for the client to give up.
This takes the test from about 1.3s to 0.35s.
@canova
canova force-pushed the optimize-cli-tests branch from 23ebe86 to f58f2fe Compare October 1, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

yarn test-all is too slow

1 participant