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.0.1, generated at 2026-09-25.

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

相關技能

custom-agents
github
定義並驗證 GitHub 自訂代理檔案、提示詞與範例。
nemoclaw-maintainer-find-review-pr
nvidia
尋找已開啟且標記為安全相關的 GitHub PR,這些 PR 具有緊急或高專案優先級,將每個 PR 連結到其對應的 issue,偵測重複項目,並呈現一個審查表格…
golang-samber-lo
samber
使用 samber/lo 為 Golang 提供的函數式程式設計輔助工具 — 超過 500 個型別安全的泛型函式,適用於切片、映射、通道、字串、數學、元組及並發處理(Map、Filter、Reduce、GroupBy、Chunk、Flatten、Find、Uniq 等)。核心不可變套件(lo)、並發變體(lo/parallel 即 lop)、原地變異(lo/mutable 即 lom)、惰性迭代器(lo/it 即 loi,適用於 Go 1.23+)以及實驗性 SIMD(lo/exp/simd)。適用於使用或採用 samber/lo 時,當程式碼庫匯入...
development
slack-messaging
anthropic
使用 mrkdwn 語法撰寫格式良好、有效的 Slack 訊息指南
managing-path-cleaning-rules
posthog
檢查URL路徑,並提議、測試、排序及應用專案層級的路徑清理規則,使動態區段(如數字ID、UUID、slug、日期)摺疊…
m365-agents-ts
microsoft
Microsoft 365 Agents SDK,適用於TypeScript/Node.js。使用AgentApplication路由、Express託管、串流回應及Copilot Studio用戶端整合,為Teams/M365/Copilot Studio建置多頻道代理程式。觸發詞:「Microsoft 365 Agents SDK」、「@microsoft/agents-hosting」、「AgentApplication」、「startServer」、「streamingResponse」、「Copilot Studio用戶端」、「@microsoft/agents-copilotstudio-client」。
productivity
flux-kontext
prime-skills
使用Flux 1 Kontext Pro(Black Forest Labs的精確局部圖像編輯模型)在RunComfy上編輯圖像——內含該模型文檔化的提示模式,使技能比對同一模型進行簡單提示能獲得更精確的輸出。記錄了Flux Kontext的優勢(單參考精確局部編輯、強大的提示控制、一致的高保真輸出)、架構(單圖像+提示),以及何時改用Nano Banana Edit / GPT Image 2 edit / Flux 2 Klein。調用...
studio-e2e-tests
supabase
撰寫並執行 Supabase Studio 的 Playwright E2E 測試。在收到要求時使用。