vitest

bởi antfu

Khung kiểm thử đơn vị nhanh Vitest được hỗ trợ bởi Vite với API tương thích Jest. Sử dụng khi viết kiểm thử, giả lập, cấu hình độ phủ, hoặc làm việc với bộ lọc kiểm thử và fixture.

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

Skills liên quan

storybook
langfuse
Use when writing or reviewing Storybook stories (`.stories.tsx`) for React components.
official
checking-deploy-timing
posthog
Xác định thời điểm một thay đổi mã PostHog đến một môi trường nhất định bằng cách đọc các chú thích triển khai GIT ẩn trong dự án và đối chiếu chúng với…
official
author-contributions
microsoft
Xác định tất cả các tệp mà một tác giả cụ thể đã đóng góp trên một nhánh so với nhánh gốc, truy vết mã qua các lần đổi tên. Sử dụng khi được hỏi ai đã chỉnh sửa cái gì, mã nào của một…
official
investigate
launchdarkly
Phân tích dữ liệu quan sát — nhật ký, dấu vết, lỗi, phiên và số liệu — để tìm nguyên nhân gốc rễ và bằng chứng có thể hành động. Sử dụng khi người dùng báo cáo lỗi, một…
official
earth2studio-data-fetch
nvidia
Lấy dữ liệu thời tiết/khí hậu qua các nguồn dữ liệu Earth2Studio cho các biến và thời gian cụ thể. KHÔNG sử dụng cho pipeline suy luận, khám phá mô hình hoặc cài đặt.
official
writing-skills
obra
Sử dụng khi tạo kỹ năng mới, chỉnh sửa kỹ năng hiện có hoặc xác minh kỹ năng hoạt động trước khi triển khai
developmentdocumentcreative
azure-containerregistry-py
microsoft
Quản lý hình ảnh container, tạo tác và kho lưu trữ trong Azure Container Registry.
official
portable-text-conversion
sanity-io
Chuyển đổi nội dung HTML và Markdown thành các khối Portable Text cho Sanity. Sử dụng khi di chuyển nội dung từ các CMS cũ, nhập HTML hoặc Markdown vào Sanity,…
official