Speed up unit tests by reusing Vitest workers - #1317
Merged
Merged
Conversation
charlespwd
marked this pull request as ready for review
October 1, 2026 12:50
karreiro
approved these changes
Oct 1, 2026
karreiro
left a comment
Contributor
There was a problem hiding this comment.
Thank you, @charlespwd 🔥
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In this PR
Reuse each Vitest worker across test files instead of starting a fresh process for every file. In local profiling, this cuts the five CI unit-test commands from about 100 seconds to about 11 seconds.
Problem
The Vitest 4 migration kept the suite at one worker but lost the old
singleForkbehavior. The suite now starts hundreds of child processes sequentially, while the test bodies themselves take only a few seconds.Solution
Run the root and Prettier suites with
isolate: falseso their files share one process and module cache.Five root tests depend on a fresh module graph, so they stay in a small isolated Vitest project. The shared setup also installs its unhandled-rejection logger once per worker process, including filtered runs and collection failures.