Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

vitest — Claude Code skill: what it does, how to install

This skill guides work with Vitest tests, mocks, coverage, filtering, and fixtures. Use it when setting up tests or checking how Vitest fits a Vite project.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add antfu/skills --skill vitest -a claude-code
Open on GitHub

What vitest does

The skill covers Vitest and Vite configuration, test and assertion APIs, hooks, and test grouping. It also explains mocks, snapshots, coverage with V8 or Istanbul, fixtures, parallel execution, and reporters.

Reference topics include the CLI, filtering by test name or file pattern, tags, node, jsdom, and happy-dom environments, type testing, and multi-project workspaces. Vitest shares configuration and plugins with Vite, so check the project setup if it does not use Vite.

The skill supports Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode. For Claude Code, install it with npx skills add antfu/skills --skill vitest -a claude-code; the skill file is at ~/.claude/skills/vitest/SKILL.md.

What it helps with

  • write tests with the appropriate assertions
  • mock modules, timers, or dates
  • filter test runs by name or file pattern
  • configure coverage with V8 or Istanbul
  • organize tests with fixtures and parallel execution

Example prompts for the agent

  • Help me configure Vitest and Vite for this project's tests.
  • Write tests for this module and add mocks with `vi`.
  • How can I filter tests by name and configure Istanbul coverage?

How to install vitest

1Skills CLI (Vercel)

npx skills add antfu/skills --skill vitest -a claude-code

2Manually: put the files in place

~/.claude/skills/vitest/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/vitest/

From the same set7

The whole set →

Similar

chrome-devtools-cli ChromeDevTools Lets AI coding agents interact with Chrome DevTools to automate clicks, inspect DOM snapshots, profile performance, and debug heap memory from the terminal. Claude Code CX Codex Cursor +1 6,700installs rust-testing affaan-m A skill for writing Rust tests: unit, integration, async, property-based, mocks and coverage. Useful when the project runs on TDD. Claude Code CX Codex Cursor +1 5,500installs frontend-design-direction affaan-m Sets a product-specific direction for web UI and helps check hierarchy, content states, responsive behavior, accessibility, and rendered results. Claude Code CX Codex Cursor +1 5,300installs nestjs-patterns affaan-m Architectural guidelines for NestJS backends, covering modular directory layouts, DTO validation, and testing. Claude Code CX Codex Cursor +1 5,000installs golang-testing affaan-m A skill that gives your agent Go testing patterns: table-driven cases, subtests, benchmarks, fuzzing and coverage. Useful when you write tests and want idiomatic Go. Claude Code CX Codex Cursor +1 5,000installs e2e-testing affaan-m Playwright E2E testing patterns covering Page Object Model setup, CI/CD configuration, flaky test quarantine, and artifact capture. Claude Code CX Codex Cursor +1 5,000installs improve-codebase-architecture Matt Pocock This skill scans a codebase for architectural friction, then builds a visual HTML report with refactoring candidates. Use it before a deeper architecture review. Claude Code 1,163,035installs design-taste-frontend Leonxlnx This skill directs the design of public pages and work screens, then checks the result in a browser through screenshots. Use it when an interface feels generic or unfinished. Claude Code CX Codex Cursor +1 673,100installs

Questions about vitest

How do I install vitest in Claude Code?

Run npx skills add antfu/skills --skill vitest -a claude-code. The skill file is available at ~/.claude/skills/vitest/SKILL.md.

What does the vitest skill do?

It guides work with Vitest configuration, test APIs, mocks, fixtures, and coverage. It also covers filtering, test environments, and parallel execution.

Which platforms does the vitest skill support?

It supports Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode.

Source text

SKILL.md · MIT
---
name: vitest
description: Vitest fast unit testing framework powered by Vite with Jest-compatible API. Use when writing tests, mocking, configuring coverage, or working with test filtering and fixtures.
metadata:
  author: Anthony Fu
  version: "2026.10.23"
  source: Generated from https://github.com/vitest-dev/vitest, scripts located at https://github.com/antfu/skills
---

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 5.1.0-beta.1, generated at 2026-10-23.

## 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) |
| Test Tags | Label tests with tags to filter runs and apply shared options | [features-test-tags](references/features-test-tags.md) |
| Reporters | Built-in reporters, default selection, CI/output config | [features-reporters](references/features-reporters.md) |
| Benchmarking | Write benchmarks with the bench fixture (Tinybench) | [features-benchmarking](references/features-benchmarking.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) |

© Anthony Fu · MIT · antfu/skills

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor