[PR #286] [CLOSED] perf: split vitest into unit and integration projects #445

Closed
opened 2026-05-06 12:39:50 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/286
Author: @southpolesteve
Created: 3/6/2026
Status: Closed

Base: mainHead: improve/vitest-workspace-split


📝 Commits (1)

  • 1409521 perf: split vitest into unit and integration projects

📊 Changes

2 files changed (+56 additions, -16 deletions)

View changed files

📝 package.json (+2 -0)
📝 vitest.config.ts (+54 -16)

📄 Description

Summary

  • Splits the vitest config into two projects: unit (28 files) and integration (24 files)
  • Adds test:unit and test:integration npm scripts for targeted runs
  • No changes to CI (full suite still runs via pnpm test)

Motivation

The full vitest suite takes ~2 minutes because fileParallelism: false forces 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, fileParallelism is a global-only setting (it cannot be set per-project), so both projects still run serially when you invoke pnpm test. The practical win is that developers and agents can now run subsets:

Command What runs Time
pnpm test All 52 files (serial) ~100s
pnpm test:unit 28 unit files only (serial) ~14s
pnpm test:integration 24 integration files only (serial) ~97s
pnpm test -- tests/routing.test.ts Single file ~3s

When multiple agents are working on the repo simultaneously, pnpm test:unit provides 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(), import createServer from Vite, or spawn dev server subprocesses. The integrationTests array in vitest.config.ts documents this and includes guidance for future test authors.

Future improvement

When vitest adds per-project fileParallelism support (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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/286 **Author:** [@southpolesteve](https://github.com/southpolesteve) **Created:** 3/6/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `improve/vitest-workspace-split` --- ### 📝 Commits (1) - [`1409521`](https://github.com/cloudflare/vinext/commit/14095219638081191dd219139b46bd92c93a3b77) perf: split vitest into unit and integration projects ### 📊 Changes **2 files changed** (+56 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `package.json` (+2 -0) 📝 `vitest.config.ts` (+54 -16) </details> ### 📄 Description ## Summary - Splits the vitest config into two projects: **unit** (28 files) and **integration** (24 files) - Adds `test:unit` and `test:integration` npm scripts for targeted runs - No changes to CI (full suite still runs via `pnpm test`) ## Motivation The full vitest suite takes ~2 minutes because `fileParallelism: false` forces 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, `fileParallelism` is a global-only setting (it cannot be set per-project), so both projects still run serially when you invoke `pnpm test`. The practical win is that developers and agents can now run subsets: | Command | What runs | Time | |---------|-----------|------| | `pnpm test` | All 52 files (serial) | ~100s | | `pnpm test:unit` | 28 unit files only (serial) | ~14s | | `pnpm test:integration` | 24 integration files only (serial) | ~97s | | `pnpm test -- tests/routing.test.ts` | Single file | ~3s | When multiple agents are working on the repo simultaneously, `pnpm test:unit` provides 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()`, import `createServer` from Vite, or spawn dev server subprocesses. The `integrationTests` array in `vitest.config.ts` documents this and includes guidance for future test authors. ## Future improvement When vitest adds per-project `fileParallelism` support (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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:39:50 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#445
No description provided.