Skip to content

Speed up unit tests by reusing Vitest workers - #1317

Merged
charlespwd merged 1 commit into
mainfrom
cp-reuse-vitest-workers
Oct 1, 2026
Merged

charlespwd merged 1 commit into
mainfrom
cp-reuse-vitest-workers

Conversation

@charlespwd

Copy link
Copy Markdown
Contributor

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 singleFork behavior. 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: false so 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.

@charlespwd
charlespwd marked this pull request as ready for review October 1, 2026 12:50
@charlespwd
charlespwd requested a review from a team as a code owner October 1, 2026 12:50

@karreiro karreiro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @charlespwd 🔥

@charlespwd
charlespwd merged commit 1ce43a6 into main Oct 1, 2026
8 checks passed
@charlespwd
charlespwd deleted the cp-reuse-vitest-workers branch October 1, 2026 13:17
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.

2 participants