perf: split vitest into unit and integration projects#286
Open
southpolesteve wants to merge 1 commit intomainfrom
Open
perf: split vitest into unit and integration projects#286southpolesteve wants to merge 1 commit intomainfrom
southpolesteve wants to merge 1 commit intomainfrom
Conversation
Test files are now categorized into two vitest projects: - unit (28 files): Pure logic tests that don't start Vite dev servers. Run with: pnpm test:unit (~14s) - integration (24 files): Tests that spin up Vite dev servers against shared fixture directories. Run with: pnpm test:integration (~97s) fileParallelism remains globally disabled (vitest 3.x limitation, it cannot be set per-project). The practical win is that agents and developers can now run 'pnpm test:unit' or 'vitest run --project unit' to skip integration tests entirely, getting feedback in seconds instead of minutes. Full suite (pnpm test) still runs everything, and CI is unchanged.
commit: |
|
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.
Summary
test:unitandtest:integrationnpm scripts for targeted runspnpm test)Motivation
The full vitest suite takes ~2 minutes because
fileParallelism: falseforces all 52 test files to run serially. This is necessary for integration tests (they race on Vite's deps optimizer cache), but the 28 unit test files don't start dev servers and don't need serial execution.With vitest 3.x,
fileParallelismis a global-only setting (it cannot be set per-project), so both projects still run serially when you invokepnpm test. The practical win is that developers and agents can now run subsets:pnpm testpnpm test:unitpnpm test:integrationpnpm test -- tests/routing.test.tsWhen multiple agents are working on the repo simultaneously,
pnpm test:unitprovides a fast feedback loop without the overhead of spinning up Vite dev servers.Integration test classification
Tests are classified as integration if they call
startFixtureServer(), importcreateServerfrom Vite, or spawn dev server subprocesses. TheintegrationTestsarray invitest.config.tsdocuments this and includes guidance for future test authors.Future improvement
When vitest adds per-project
fileParallelismsupport (tracked in vitest 4.x), unit tests can run in parallel while integration tests remain serial. This would further reduce the full suite runtime./bigbonk review this