About vitest
vitest is a skill for developers working with tests in Vite projects, covering test writing, configuration, mocks, coverage, Browser Mode, and migration. Its guidance targets Vitest 5.x and emphasizes choosing commands for the project and verifying changes.
Key features
- 01Guide Vitest configuration and test execution
- 02Cover mocks, timers, and snapshots
- 03Explain coverage and Browser Mode
- 04Guide projects, worker pools, and reporters
- 05Support Jest and Vitest version migrations
Use cases
- 01Write or run tests in a Vite project
- 02Adjust mocks, snapshots, or coverage settings
- 03Investigate browser testing or migration issues
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ dobroslavradosavljevic/ skills --skill vitestAfter installing, type/vitestin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
agents/openai.yamlreferences/config-cli-api.mdcoverage-browser-projects.mdmigration.mdmocking-snapshots.mdsource-map.mdusage-guide.mdDetails
From the project READMEVitest
Use this skill when work touches Vitest: writing/running tests, config, mocks/snapshots, coverage, browser mode, projects/pools, reporters, or migrating from Jest / Vitest 3 / Vitest 4.
Snapshot: [email protected] (2026-10-01). Refresh from source-map.md if versions differ.
Workflow
- Inspect the local Vitest surface:
- Package versions:
vitestand aligned@vitest/*(snapshot 5.0.3). Node^22.12 || ^24 || >=26. Vite peer^6.4 || ^7 || ^8(required; Yarn must listviteexplicitly). - Config: dedicated
vitest.config.*(overridesvite.configentirely) vstest: {}inside Vite config. Config is not looked up from parent directories. - Scripts: prefer
vitest runfor CI; do not usebun test(Bun’s runner) when the project uses Vitest — usebun run test/bunx vitest. - Environment:
node(default) vsjsdom/happy-domvs Browser Mode projects. - Artifacts:
.vitest/at the project root (gitignore it).
- Package versions:
- For day-to-day how-to, follow usage-guide.md first.
- Refresh docs when versions drift or the task is browser/coverage/migration. Start from source-map.md.
- Route deeper detail:
- Config, CLI, test API, environments, setup: config-cli-api.md.
vimocks,vi.when, timers, env stubs, snapshots: mocking-snapshots.md.- Coverage, browser mode, projects, pools, reporters, bench: coverage-browser-projects.md.
- Jest / Vitest 3 → 4 / 4 → 5: migration.md.
- Prefer Vitest 5.x APIs (
projectswith defaultextends: true,maxWorkers, browser provider factories,benchas a test-context fixture,vi.when). Keep@vitest/*packages on the same version asvitest. - Verify with the narrowest useful command (
vitest run path -t "name", coverage, or browser project). Usevitest doctoronly when tuning pool/isolate/cache.
Core Judgment
- Vitest is a Vite-powered test runner with a Jest-compatible API — not Bun’s built-in
bun test. - CI / hooks: always
vitest run(or--run). Plainvitestwatches and hangs non-interactively unless CI/non-TTY forces run. - Import from
vitestunlessglobals: true. Prefer explicit imports for agent clarity. vi.mock/vi.unmock/vi.hoistedare hoisted and must be top-level — nested calls throw. Factories cannot close over non-hoisted locals.clearMocksdefaults totrue(call history cleared before each test; implementations stay). Concurrent tests that share mocks may needclearMocks: false.- Concurrent tests + snapshots/asserts: use context
expectfrom the test callback, not globalexpect. - Always
awaitresolves/rejects/toMatchFileSnapshot/expect.poll— unawaited async assertions fail the test. - Default pool is
forks. Prefer it overthreadswhen native addons misbehave. - A dedicated
vitest.config.*ignoresvite.configoptions — usemergeConfigwhen extending Vite plugins/aliases. - Inline
test.projectsinherit the root config (extends: truedefault) and may share the Vite server. File/dir projects do not inherit. - Coverage is root-only in projects; set
coverage.includeexplicitly. Patterns match paths relative to the project root (nocontains). - Browser Mode is not
environment: 'jsdom'— usebrowser.enabled+ provider packages. Locators are exact by default. benchis not a top-level import — use the{ bench }fixture inside*.bench.*files.- Vite transforms tests but does not typecheck — use optional
typecheckor projecttscseparately.
Verification
Prefer repository-owned commands. For meaningful Vitest work, cover the relevant subset:
bunx vitest --versionand confirm@vitest/*version alignment.- Focused
vitest run <file> -t "<name>"(or:linefilter). Full names use>(-t 'suite > test'). - Snapshot updates only with deliberate
-u/ watchu; review diffs. - Coverage:
vitest run --coveragewhen thresholds or reports matter. - Browser project: headless chromium smoke when UI/component tests change.
- Migration: no remaining
workspace, string browser providers,poolOptions,test(name, fn, options), nestedvi.mock, top-levelbenchimport,test.sequential, orbrowser.api.
Report which checks ran, which did not, and any Vitest version assumptions that remain.