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.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

Skills liên quan

expo-upgrade
expo
Khung (Mã nguồn mở). Hướng dẫn nâng cấp phiên bản Expo SDK và sửa lỗi phụ thuộc
apidevelopmenttesting
ui-sdk
vercel
Xây dựng giao diện bằng ui-sdk trong React, Vue, Svelte, Solid hoặc web components. Bao gồm việc chọn và kết hợp các thành phần của thư viện, xây dựng thành phần hoặc hành vi mà thư viện không cung cấp từ @ui-sdk/core (như stepper, splitter, danh sách chuyển mục hoặc bộ chọn emoji), giúp agent sử dụng giao diện thông qua createAgent, công cụ dành cho agent và WebMCP, cũng như kiểm thử bàn phím, tiêu điểm, ARIA, kết xuất phía máy chủ và bố cục từ phải sang trái, bao gồm cả việc viết kiểm thử cho một thành phần hiện có. Sử dụng bất cứ khi nào dự án có @ui-sdk/*...
testingdesigndevelopment
workers-development
cloudflare
Chạy, kiểm tra và gỡ lỗi Cloudflare Workers trong quá trình phát triển cục bộ bằng cf dev, wrangler dev hoặc plugin Cloudflare Vite; dùng Local Explorer để đọc và khởi tạo dữ liệu binding, đồng thời truy vấn trace và log cục bộ. Ngoài ra, chuyển hướng hoạt động gỡ lỗi trên môi trường production đến tính năng quan sát của Workers. Dùng để gỡ lỗi các yêu cầu, bất kể dự án có sử dụng Wrangler hay không.
devopstestingdevelopment
workers-profiling
cloudflare
Phân tích hiệu năng hoặc gỡ lỗi mức sử dụng CPU và phân bổ bộ nhớ trong Cloudflare Workers và Durable Objects đã triển khai. Sau đó, sử dụng thông tin này để tối ưu hóa mã của bạn.
devopstestingdevelopment
accessibility
addyosmani
Kiểm tra và cải thiện khả năng truy cập web theo hướng dẫn WCAG 2.2. Sử dụng khi được yêu cầu "cải thiện khả năng truy cập", "kiểm tra a11y", "tuân thủ WCAG", "hỗ trợ trình đọc màn hình", "điều hướng bàn phím" hoặc "làm cho có thể truy cập".
developmenttestingcode-review
accessibility-engineering
addyosmani
Kiểm tra các giao diện hiện có để xác minh mức độ tuân thủ WCAG 2.2 AA và khắc phục các lỗi được phát hiện. Sử dụng khi kiểm tra khả năng truy cập của trang hoặc thành phần, chạy axe-core hoặc pa11y, phân loại lỗi a11y, hoặc kiểm tra các vấn đề về trình đọc màn hình và độ tương phản trước khi phát hành.
developmenttestingdesign
audit-website
squirrelscan
Kiểm tra trang web bằng CLI squirrelscan và sửa các phát hiện trong mã. Chạy các danh mục quy tắc về SEO, hiệu suất, bảo mật, kỹ thuật, nội dung, khả năng tiếp cận và 15 danh mục khác (hơn 249 quy tắc), trả về báo cáo tối ưu hóa cho LLM, sau đó thực hiện vòng lặp sửa lỗi lặp đi lặp lại, ánh xạ vấn đề đến tệp nguồn, áp dụng bản sửa lỗi và kiểm tra lại cho đến khi trang web đạt điểm tốt. Sử dụng để phát hiện và đánh giá các vấn đề của trang web hoặc ứng dụng web và đưa chúng đến trạng thái đã sửa.
developmenttestingweb-scraping
better-accessibility
jakubkrehel
Đánh giá và khắc phục hành vi bàn phím và tiêu điểm, ARIA, tên dễ truy cập, biểu mẫu, thông báo cho trình đọc màn hình, chuyển động và thu phóng theo WCAG 2.2.
developmenttestingcode-review