Install this skill
npx skills add antfu/skillsWorks across Claude Code, Cursor, Codex, Copilot & Antigravity
What this skill does
- β’Run unit tests with high-performance HMR-like speed
- β’Mock functions, modules, timers, and dates via vi utilities
- β’Execute tests in parallel using multi-threaded workers
- β’Generate code coverage reports using V8 or Istanbul
- β’Perform type-level validation using expectTypeOf and assertType
When to use it
- βYou are maintaining a project using Vite or Nuxt
- βYou need a fast, Jest-compatible environment for TypeScript code
- βYou want to perform snapshot testing on UI components
- βYou need to verify complex business logic with mocked dependencies
When not to use it
- βYou are working in a non-Node.js, non-browser environment like pure Rust
- βYou need end-to-end integration tests that require a full browser engine
- βYour project relies on legacy CJS-only build systems that conflict with Vite
How to invoke it
Example prompts that trigger this skill:
- βRun the test suite for the current projectβ
- βCreate a new test file for my component using Vitest syntaxβ
- βMock the dependency in this test fileβ
- βCheck the code coverage for the latest changesβ
- βFilter the test execution to only run files matching a specific patternβ
Example workflow
- Configure Vitest within the Vite project settings
- Define unit tests using the test and expect APIs
- Use vi.mock to isolate functions from external dependencies
- Run tests in watch mode to see immediate feedback
- Generate a coverage report to identify untested code paths
Prerequisites
- βNode.js
- βVite
Pitfalls & limitations
- !Config drift between Vite development and Vitest environment settings
- !Incompatibility with certain non-standard ESM plugins
- !Memory management overhead when running massive test suites in parallel
FAQ
How it compares
Unlike manual testing or generic scripts, this agent manages the full Vitest lifecycle, including complex module resolution and mocking configurations that usually require significant boilerplate.
Source & trust
From the source: βVitest is a next-generation testing framework powered by Vite. It provides a Jest-compatible API with native ESM, TypeScript, and JSX support out of the box. Vitest shares the same config, transformers, resolvers, and plugins with your Vite app. **Key Features:** - Vite-native: Uses Vite's transformβ¦β
View the full SKILL.md source
Vitest is a next-generation testing framework powered by Vite. It provides a Jest-compatible API with native ESM, TypeScript, and JSX support out of the box. Vitest shares the same config, transformers, resolvers, and plugins with your Vite app. **Key Features:** - Vite-native: Uses Vite's transformation pipeline for fast HMR-like test updates - Jest-compatible: Drop-in replacement for most Jest test suites - Smart watch mode: Only reruns affected tests based on module graph - Native ESM, TypeScript, JSX support without configuration - Multi-threaded workers for parallel test execution - Built-in coverage via V8 or Istanbul - Snapshot testing, mocking, and spy utilities > The skill is based on Vitest 3.x, generated at 2026-01-28. ## Core | Topic | Description | Reference | |-------|-------------|-----------| | Configuration | Vitest and Vite config integration, defineConfig usage | [core-config](references/core-config.md) | | CLI | Command line interface, commands and options | [core-cli](references/core-cli.md) | | Test API | test/it function, modifiers like skip, only, concurrent | [core-test-api](references/core-test-api.md) | | Describe API | describe/suite for grouping tests and nested suites | [core-describe](references/core-describe.md) | | Expect API | Assertions with toBe, toEqual, matchers and asymmetric matchers | [core-expect](references/core-expect.md) | | Hooks | beforeEach, afterEach, beforeAll, afterAll, aroundEach | [core-hooks](references/core-hooks.md) | ## Features | Topic | Description | Reference | |-------|-------------|-----------| | Mocking | Mock functions, modules, timers, dates with vi utilities | [features-mocking](references/features-mocking.md) | | Snapshots | Snapshot testing with toMatchSnapshot and inline snapshots | [features-snapshots](references/features-snapshots.md) | | Coverage | Code coverage with V8 or Istanbul providers | [features-coverage](references/features-coverage.md) | | Test Context | Test fixtures, context.expect, test.extend for custom fixtures | [features-context](references/features-context.md) | | Concurrency | Concurrent tests, parallel execution, sharding | [features-concurrency](references/features-concurrency.md) | | Filtering | Filter tests by name, file patterns, tags | [features-filtering](references/features-filtering.md) | ## Advanced | Topic | Description | Reference | |-------|-------------|-----------| | Vi Utilities | vi helper: mock, spyOn, fake timers, hoisted, waitFor | [advanced-vi](references/advanced-vi.md) | | Environments | Test environments: node, jsdom, happy-dom, custom | [advanced-environments](references/advanced-environments.md) | | Type Testing | Type-level testing with expectTypeOf and assertType | [advanced-type-testing](references/advanced-type-testing.md) | | Projects | Multi-project workspaces, different configs per project | [advanced-projects](references/advanced-projects.md) |
Quoted from antfu/skills for reference β see the original for the authoritative, latest version.
π Full skill instructions β original source: antfu/skills
How to Use This Skill Unit
Option A: Project-Specific (Recommended)
- Click "Download" above
- In your project, create the directory:
.agent/skills/vitest/ - Save the file as
SKILL.md - The agent will automatically discover the skill based on its description.
Option B: Global Installation (All Agents)
Save the file to these locations to make it available across all projects:
- Claude Code:
~/.claude/skills/antfu/skills/vitest/SKILL.md - Cursor:
~/.cursor/skills/antfu/skills/vitest/SKILL.md - Antigravity:
~/.gemini/antigravity/skills/antfu/skills/vitest/SKILL.md
π Install with CLI:npx skills add antfu/skills