vitest

作者: antfu

由 Vite 驱动的快速单元测试框架,兼容 Jest API。适用于编写测试、模拟、配置覆盖率、处理测试过滤和夹具。

npx skills add https://github.com/antfu/skills --skill vitest

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.x (beta), generated at 2026-06-22.

Core

TopicDescriptionReference
ConfigurationVitest and Vite config integration, defineConfig usagecore-config
CLICommand line interface, commands and optionscore-cli
Test APItest/it function, modifiers like skip, only, concurrentcore-test-api
Describe APIdescribe/suite for grouping tests and nested suitescore-describe
Expect APIAssertions with toBe, toEqual, matchers and asymmetric matcherscore-expect
HooksbeforeEach, afterEach, beforeAll, afterAll, aroundEachcore-hooks

Features

TopicDescriptionReference
MockingMock functions, modules, timers, dates with vi utilitiesfeatures-mocking
SnapshotsSnapshot testing with toMatchSnapshot and inline snapshotsfeatures-snapshots
CoverageCode coverage with V8 or Istanbul providersfeatures-coverage
Test ContextTest fixtures, context.expect, test.extend for custom fixturesfeatures-context
ConcurrencyConcurrent tests, parallel execution, shardingfeatures-concurrency
FilteringFilter tests by name, file patterns, tagsfeatures-filtering
Test TagsLabel tests with tags to filter runs and apply shared optionsfeatures-test-tags
ReportersBuilt-in reporters, default selection, CI/output configfeatures-reporters
BenchmarkingWrite benchmarks with the bench fixture (Tinybench)features-benchmarking

Advanced

TopicDescriptionReference
Vi Utilitiesvi helper: mock, spyOn, fake timers, hoisted, waitForadvanced-vi
EnvironmentsTest environments: node, jsdom, happy-dom, customadvanced-environments
Type TestingType-level testing with expectTypeOf and assertTypeadvanced-type-testing
ProjectsMulti-project workspaces, different configs per projectadvanced-projects

相关技能

adr-skill
vercel
创建并维护针对智能体编码工作流优化的架构决策记录(ADR)。在需要提议、编写、更新、接受/拒绝……时使用。
official
skill-manager
anthropic
参考:通过合法构建者中心安装的社区技能的详细卸载、禁用和重新启用工作流程。默认安全——拒绝触碰……
official
skill-evolution
nvidia
在创建、编辑或决定是否更新此仓库中的任何AI编码代理技能(包括对现有技能行为的修正等)之前使用。
official
messages
github
向安全输出消息系统添加新消息类型的说明
official
jetson-validate-image
nvidia
在jetson-flash-image之后使用,用于对已刷写的被测设备运行静态BSP检查、目标端冒烟/回归测试,或两者兼有。不适用于构建或刷写步骤。触发条件:…
official
winui3-migration-guide
github
将UWP应用迁移至WinUI 3的完整参考,包含迁移前后的代码示例。映射所有从Windows.UI.Xaml.*到Microsoft.UI.Xaml.*的命名空间变更,以及线程、窗口和对话框API。涵盖Copilot最常见的三个错误:未使用XamlRoot的ContentDialog、MessageDialog用法和CoreDispatcher模式。包含窗口管理、选择器、后台任务、设置和GetForCurrentView()替代方案的迁移表。提供15项迁移检查清单……
official
mcore-linting-and-formatting
nvidia
对Megatron-LM进行代码检查与格式化,涵盖运行autoformat.sh、工具(ruff、black、isort、pylint、mypy)以及代码风格规则。
official
nat-workflow-creation
nvidia
Use when creating, editing, validating, running, or troubleshooting NeMo Agent Toolkit workflow YAML, component discovery, LLM configuration, and common `nat`…
official