Configuration
Configuration and runner scripts are repository-owned. Add or migrate config only for the requested behavior.
Keep project-specific environment and setup ownership. Use
test.projectsfor distinct projects and give each a stable name; a project container does not run tests itself. Do not change a suite-wide environment for one exception.Keep aliases consistent with TypeScript and Vite resolution; aliases do not repair arbitrary externalized dependencies.
Setup files are for truly suite-wide polyfills, matcher registration, cleanup, and mocks. Keep scenario data and heavy initialization in owned fixtures or tests.
Coverage is opt-in. When requested, specify the intended source set and retain repository thresholds; do not use a provider change or lower threshold to hide a bad include/exclude set.
For v4 migration, replace removed workspace/match-glob and worker settings with the documented project/worker model;
coverage.alland thebasicreporter are gone,verboseis flat, and browser APIs come fromvitest/browser. See the v4 migration guide.For v5 migration, require Vite 6.4+ and Node.js 22.12+;
viteis now a peer dependency, so Yarn projects must add it. Audit these changes, which can silently alter results rather than fail:clearMocksdefaults totrue, clearing call history recorded in setup files, at module scope, or inbeforeAll.- Inline
test.projectsinherit the root config (extends: true, arrays such assetupFilesappend) and share its Vite server (sharedViteServer). A referenced config that declaresprojectsnow expands into nested projects, so do not merge a root config that defines them. -t/testNamePatternmatches the' > '-joined full name;test.each/test.fortitles no longer quote$strings.- Coverage
include/excludematch project-relative paths withoutcontains; glob thresholds no longer inheritperFile. - Config files are no longer found in parent directories; pass
--configfrom a subdirectory. - Artifacts live under
.vitest/, and thejsonandjunitreporters write files instead of stdout unlessstdout: trueis set. VITEST_POOL_IDandVITEST_WORKER_IDare 1-based.- Browser locators and
toHaveTextContentmatch exactly (partial or regex matching moved totoMatchTextContent), andbrowser.apimoved to top-levelapi.
These now fail loudly: nested
vi.mock/vi.unmock/vi.hoisted, unawaitedresolves/rejects/toMatchFileSnapshot, lateexpect.poll, removedsequentialAPIs (use{ concurrent: false }), module-scopebench(now a test-context fixture), and the removedvitest/coverage,vitest/reporters(usevitest/node),vitest/environments, andvitest/snapshot(usevitest/runtime) entry points. Check the installed version's migration guide rather than carrying shims.
Use repository reporter conventions. Otherwise prefer minimal agent-oriented output: Vitest 4.1 introduced
--reporter=agent; current versions call it minimal and retain agent as an alias. Use automatic agent detection
when available, and check the installed version's reporter documentation
before passing a flag. See configuration,
projects, and aliases.