vitest

antfu/skills · Agent Skill

Vitest testing best practices for unit tests, mocking, coverage, fixtures, and test filtering.

Jump to install ↓

Overview

PublisherantfuCommunity
Repositoryantfu/skills ↗
Skill foldervitest
Stars6,011
Forks338
Bundled files21
LicenseMIT
Last updatedOctober 23, 2026
LinksSkill source ↗ · Repository ↗

Mozgi check

What we found in the skill files. Details come with a subscription.

Security
low risk · no obvious risks found — the full report shows the details
Compatibility
instructions only — works with most agents
Similar skills
62 similar skills found
Also with subscription

Installation

A skill is a folder with a SKILL.md file. Pick your agent and run the commands in a terminal (macOS, Linux or Git Bash on Windows) from your project root.

Copy the prompt into Claude, Codex or another assistant: it will review the skill and install it for you.

Install the “vitest” skill from mozgi.io (https://mozgi.io/skills/antfu-vitest/) for me.

1. Download the archive: https://mozgi.io/skills/antfu-vitest/download
   If it fails, take the skill folder from the source: https://github.com/antfu/skills/tree/main/skills/vitest
2. Read SKILL.md and the other files. Check the skill is safe: no hidden commands, no sending data elsewhere, no scripts doing something other than described. If anything looks suspicious, stop and tell me.
3. Put the “vitest” folder into your agent's skills folder: .claude/skills/ for Claude Code, .agents/skills/ for Codex, .cursor/skills/ for Cursor, .gemini/skills/ for Gemini CLI. Inside the project if we are in one, otherwise in the home folder (~/.claude/skills/ etc.).
4. Make sure <skills folder>/vitest/SKILL.md exists.
5. Briefly tell me what this skill does and offer to try it on my task.

If you cannot do a step yourself, tell me what to click or type.

Review the source files

21 files Download Zip

Read SKILL.md and any companion files before deciding whether to install. Click a file to preview it.

SKILL.md contents

Original author text · read-only

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 ↗ |

| CLI | Command line interface, commands and options | core-cli ↗ |

| Test API | test/it function, modifiers like skip, only, concurrent | core-test-api ↗ |

| Describe API | describe/suite for grouping tests and nested suites | core-describe ↗ |

| Expect API | Assertions with toBe, toEqual, matchers and asymmetric matchers | core-expect ↗ |

| Hooks | beforeEach, afterEach, beforeAll, afterAll, aroundEach | core-hooks ↗ |

Features

| Topic | Description | Reference |

|-------|-------------|-----------|

| Mocking | Mock functions, modules, timers, dates with vi utilities | features-mocking ↗ |

| Snapshots | Snapshot testing with toMatchSnapshot and inline snapshots | features-snapshots ↗ |

| Coverage | Code coverage with V8 or Istanbul providers | features-coverage ↗ |

| Test Context | Test fixtures, context.expect, test.extend for custom fixtures | features-context ↗ |

| Concurrency | Concurrent tests, parallel execution, sharding | features-concurrency ↗ |

| Filtering | Filter tests by name, file patterns, tags | features-filtering ↗ |

| Test Tags | Label tests with tags to filter runs and apply shared options | features-test-tags ↗ |

| Reporters | Built-in reporters, default selection, CI/output config | features-reporters ↗ |

| Benchmarking | Write benchmarks with the bench fixture (Tinybench) | features-benchmarking ↗ |

Advanced

| Topic | Description | Reference |

|-------|-------------|-----------|

| Vi Utilities | vi helper: mock, spyOn, fake timers, hoisted, waitFor | advanced-vi ↗ |

| Environments | Test environments: node, jsdom, happy-dom, custom | advanced-environments ↗ |

| Type Testing | Type-level testing with expectTypeOf and assertType | advanced-type-testing ↗ |

| Projects | Multi-project workspaces, different configs per project | advanced-projects ↗ |

Frequently asked questions

What does the vitest skill do?

Vitest testing best practices for unit tests, mocking, coverage, fixtures, and test filtering.

How do I install vitest?

Open the “Installation” block on this page and pick your agent — Claude Code, Codex, Cursor or Gemini CLI — for ready-made commands that copy the skill folder to the right place. Or copy the prompt from the “Via assistant” tab and let the assistant review and install the skill.

Which AI models work with vitest?

Skills are plain Markdown instructions (the Agent Skills format), so vitest works with any agent that reads SKILL.md: Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and more. The model loads the instructions only when a task matches the skill's description.

Is vitest free?

The skill is published openly by antfu under the MIT license. The skill itself costs nothing — you only pay your AI provider for the tokens you use.

Is it safe to install skills?

A skill is a set of instructions your agent will follow, so read SKILL.md and its companion files before installing. Scripts in the skill folder only run if your agent runs them — keep an eye on what it does and do not grant unnecessary permissions.

How is a skill different from an MCP server or a plugin?

An MCP server or plugin gives the model new tools — code that runs and returns a result. A skill gives it knowledge and process: how to approach a task, which steps to follow and what good output looks like. It needs no server or API key.

Related skills

All skills →