Review Vitest
Review the Vitest setup for alignment with current official Vitest and Cloudflare Workers testing best practices - shared config correctness, pool selection, agent-friendly output, and the repo's unit/integration testing split. Your reply must be a plan of suggested changes: concise, actionable, structured - not only prose.
Invocation
Text after the slash command is additional scope/focus (e.g. "workers pool only", "reporters") - narrow the review accordingly.
Ground truth (mandatory)
Your pre-trained knowledge of Vitest may be outdated. Do not draft suggestions from memory alone.
- Resolve "Vitest" via the Context7 MCP (
resolve-library-id→query-docs) at v4: config API (mergeConfig/defineConfig), pool options (threads/forks/vmThreads), reporter list (including agent-aware auto-detection), project/workspace patterns, experimental flags validity. - Also resolve "@cloudflare/vitest-plugin" (or "Cloudflare Workers" docs) for current Workers-pool guidance; prefer the cloudflare-docs MCP for Workers testing questions.
- For anything Context7 lacks, use Firecrawl search/scrape restricted to official domains (
vitest.dev,developers.cloudflare.com/workers/testing/) - vitest config reference, Workers testing guide,createTestHarness()reference. - Version currency: catalog
vitest,@cloudflare/vitest-pluginin pnpm-workspace.yaml vs latest stable; flag deprecated config keys still present in presets or per-app configs. - Cite the retrieved source next to every finding; label anything unverifiable as Unverified.
Scope artifacts
- packages/vitest-config/src/index.ts (
defineNodeConfig) and src/workers.ts (defineWorkersConfig) - Per-app configs: apps/front-app/vitest.config.ts, apps/worker-api/vitest.config.mts
- Suites under
apps/*/tests/; repo testing-split policy (root +packages/vitest-config/AGENTS.md) - Root scripts
test/test:watchturbo wiring
Analysis axes
- Shared defaults: mock lifecycle (
restoreMocks/clearMocks/unstub) coherent;passWithNoTestsacceptable only as starter scaffolding - flag if permanent; include globs match reality. - Pool selection: Node suites on
threads+isolate: falsejustified by cleanup discipline (verify tests actually clean up); Workers suites never isolate:false/custom env; no cross-contamination between entries (Node apps must not resolve the Cloudflare pool package). - Workers testing split: single-Worker route tests inside workerd via the Vitest pool; multi-Worker integration reserved for Wrangler
createTestHarness()from a Node suite - confirm no drift. - Reporter & CI behavior: agent-aware reporter detection preserved (no custom reporters defeating it); GitHub job summaries intact; watch vs run mode wiring correct.
- Version currency: experimental flags (
fsModuleCache) still valid at installed version; new stable options worth adopting.
DX & AI-agentic workflow
Verify agent-friendliness: test runs fast enough for iterative agents (per-app filter documented); failure output parseable; DOM/RTL depth delegated to the front-vitest skill rather than duplicated.
Steps
- Collect ground truth before reading config.
- Read both preset entries and every per-app config; sample one Node and one Workers suite.
- Walk each analysis axis; note findings or explicit one-line "no issues".
- Compose the plan grouped Critical / Improvements / Optional with what, where, why, and source citations.
Output format
- Critical - broken isolation, pool misuse, deprecated-and-failing config.
- Improvements - speed and split-policy alignment with current guidance.
- Optional - nice-to-haves; prefix pure polish with Nit:.
Read-only review: produce the plan only; implement nothing unless explicitly asked afterwards.