vitest

作者: antfu

由 Vite 驅動、相容 Jest API 的 Vitest 快速單元測試框架。適用於撰寫測試、模擬、配置覆蓋率,或處理測試篩選與固定測試資料。

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、代理工具和 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 最佳化的報告,接著驅動反覆修正循環,將問題對應至原始檔案、套用修正,並重新稽核,直到網站獲得良好評分。可用於發現並評估網站或網頁應用程式的問題,並將其導向修正完成。
developmenttestingweb-scraping
better-accessibility
jakubkrehel
檢查並修正鍵盤與焦點行為、ARIA、無障礙名稱、表單、螢幕閱讀器公告、動態效果與縮放,使其符合 WCAG 2.2。
developmenttestingcode-review