vitest

Write, configure, and run Vitest unit tests with Vite-native tooling.

1|Updated Aug 11, 2026
One-click install
npx skills add https://github.com/Chia1104/agent-air --skill vitest-chia1104
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: vitest
Source: https://github.com/Chia1104/agent-air/tree/main/skills/shared/vitest
Command: npx skills add https://github.com/Chia1104/agent-air --skill vitest-chia1104

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Setting up and maintaining a fast JavaScript/TypeScript test suite requires deep knowledge of Vitest's configuration, mocking APIs, coverage providers, and version-specific breaking changes, which is time-consuming to learn from scattered documentation. ## Core Features & Use Cases - Test Authoring Guidance: Covers the test/describe/expect APIs, lifecycle hooks, parameterized tests, fixtures with test.extend, and type-level testing with expectTypeOf. - Mocking & Utilities: Documents vi.fn, vi.spyOn, module mocking, fake timers, vi.when conditional mocking, and environment stubbing. - Configuration & Scale: Explains vitest.config.ts setup, multi-project workspaces, sharding for CI, coverage with V8 or Istanbul, reporters, and v4/v5 migration changes. - Use Case: When migrating a Jest suite to Vitest, consult the references to configure jsdom environments, rewrite mocks with vi utilities, and set up sharded CI runs with merged blob reports. ## Quick Start Use the vitest skill to help me configure a Vitest project with jsdom environment, coverage thresholds, and mocked API calls for my TypeScript app.

Frequently Asked Questions about vitest

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure Vitest with an existing Vite config?▼

Add a test property to vite.config.ts with a Vitest types reference, or create a separate vitest.config.ts which takes priority. Use mergeConfig from vitest/config to combine separate config files when needed.

How to mock modules and functions in Vitest?▼

Use vi.mock for hoisted module mocking, vi.fn for mock functions, and vi.spyOn to track existing methods. For dynamic imports use vi.doMock, and use vi.hoisted to reference variables inside mock factories.

Vitest vs Jest: can I migrate my test suite?▼

Vitest provides a Jest-compatible API, so most suites migrate by swapping imports to vitest and adjusting configuration. Watch for v4/v5 changes like the forks pool default, removed poolOptions, and removed test.sequential.

Does Vitest support browser DOM testing?▼

Yes, Vitest supports jsdom and happy-dom environments configured globally or per file with the @vitest-environment comment. For real browser testing, use Vitest Browser Mode with providers like Playwright.

Why is my Vitest coverage report missing uncovered files?▼

Since v4, coverage.all was removed, so only files loaded during the run are reported by default. Set coverage.include explicitly, for example src/**/*.ts, to report uncovered source files too.

How do I split Vitest tests across CI machines?▼

Use the --shard=index/count flag on each machine with the blob reporter, then run vitest --merge-reports to combine results into a final junit or json report. Coverage can also be merged this way.