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

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

相关技能

expo-upgrade
expo
框架(开源)。升级Expo SDK版本及修复依赖问题的指南。
apidevelopmenttesting
ui-sdk
vercel
使用 ui-sdk 在 React、Vue、Svelte、Solid 或 Web Components 中构建界面。涵盖如何选择和组合其组件、使用 @ui-sdk/core 构建它未提供的组件或行为(例如步骤条、分隔器、传输列表或表情选择器)、通过 createAgent、agent 工具和 WebMCP 让代理能够使用界面,以及测试键盘操作、焦点、ARIA、服务器端渲染和从右到左布局,包括为现有组件编写测试。只要项目中有 @ui-sdk/*...,就使用此技能。
testingdesigndevelopment
workers-development
cloudflare
在本地开发期间,使用 cf dev、wrangler dev 或 Cloudflare Vite 插件运行、检查和调试 Cloudflare Workers;使用 Local Explorer 读取和填充绑定数据,并查询本地追踪记录和日志。也可将生产环境调试请求路由到 Workers observability。无论项目是否使用 Wrangler,均可用于调试请求。
devopstestingdevelopment
workers-profiling
cloudflare
对已部署的 Cloudflare Workers 和 Durable Objects 进行 CPU 使用情况和内存分配的性能分析或调试。然后利用这些信息优化代码。
devopstestingdevelopment
accessibility
addyosmani
根据WCAG 2.2指南审计并改进网页无障碍性。当被要求“改进无障碍性”、“无障碍审计”、“WCAG合规”、“屏幕阅读器支持”、“键盘导航”或“实现无障碍”时使用。
developmenttestingcode-review
accessibility-engineering
addyosmani
审计现有界面是否符合 WCAG 2.2 AA,并修复发现的违规问题。适用于审计页面或组件的无障碍性、运行 axe-core 或 pa11y、排查 a11y 违规问题,或在发布前检查屏幕阅读器和对比度问题。
developmenttestingdesign
audit-website
squirrelscan
使用squirrelscan CLI审计网站,并根据发现结果修复代码。运行SEO、性能、安全、技术、内容、无障碍及其他15类规则(249+条规则),返回一份针对LLM优化的报告,然后驱动迭代修复循环,将问题映射到源文件,应用修复,并重新审计,直到网站评分良好。用于发现和评估网站或Web应用的问题,并推动问题得到修复。
developmenttestingweb-scraping
better-accessibility
jakubkrehel
根据 WCAG 2.2 审查并修复键盘和焦点行为、ARIA、无障碍名称、表单、屏幕阅读器播报、动态效果和缩放。
developmenttestingcode-review