vitest

โดย antfu

เฟรมเวิร์กการทดสอบหน่วยความเร็วสูง Vitest ที่ขับเคลื่อนโดย Vite พร้อม API ที่เข้ากันได้กับ Jest ใช้เมื่อเขียนทดสอบ, สร้างม็อก, กำหนดค่าความครอบคลุม, หรือทำงานกับการกรองการทดสอบและฟิกซ์เจอร์

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

Skills ที่เกี่ยวข้อง

feature-flags
facebook
จัดการ React feature flags ข้ามช่องทาง ควบคุมการทดสอบแบบมีเงื่อนไข และดีบักข้อผิดพลาดในการทดสอบที่เฉพาะเจาะจงกับแฟล็ก ไฟล์แฟล็กสี่ไฟล์ควบคุมค่าเริ่มต้นและการแทนที่เฉพาะช่องทาง (canary, www, React Native, test renderer) โดยมีแฟล็ก __VARIANT__ ที่จำลอง gatekeepers ซึ่งถูกทดสอบทั้งสองสถานะ ใช้ pragma @gate flagName เพื่อข้ามการทดสอบทั้งหมดเมื่อแฟล็กไม่พร้อมใช้งาน หรือใช้ inline gate() เพื่อแยกสาขาการยืนยันเมื่อพฤติกรรมแตกต่างกัน การเพิ่มแฟล็กใหม่ต้องมีรายการในไฟล์หลักและไฟล์ fork ทั้งหมด...
write-endpoints
cloudflare
คู่มือฉบับสมบูรณ์สำหรับการสร้าง OpenAPI endpoints ด้วย chanfana - การกำหนด schema, การตรวจสอบคำขอ, การดำเนินการ CRUD, การรวมฐานข้อมูล D1 และ…
blog-post
langchain-ai
การเขียนบล็อกโพสต์แบบยาว พร้อมการมอบหมายงานวิจัย เทมเพลตเนื้อหาที่มีโครงสร้าง และภาพปกที่สร้างโดย AI มอบหมายการวิจัยให้กับตัวแทนย่อยก่อนเขียน โดยเก็บผลลัพธ์ในรูปแบบมาร์กดาวน์เพื่อใช้อ้างอิงและบริบท บังคับใช้โครงสร้างโพสต์ห้าส่วน: การดึงดูดความสนใจ บริบท เนื้อหาหลัก (3–5 หัวข้อ) การประยุกต์ใช้จริง และบทสรุปพร้อมคำกระตุ้นการตัดสินใจ สร้างภาพปกที่ปรับแต่งเพื่อ SEO โดยใช้พรอมต์โดยละเอียดที่ครอบคลุมหัวข้อ สไตล์ องค์ประกอบ สี และแสง ส่งออกโพสต์ไปยัง...
svelte-code-writer
sveltejs
เครื่องมือ CLI สำหรับการค้นหาเอกสาร Svelte 5 และวิเคราะห์โค้ดพร้อมระบบแก้ไขอัตโนมัติในตัว คำสั่งหลักสามคำสั่ง: list-sections เพื่อเรียกดูเอกสารที่มี, get-documentation เพื่อดึงเอกสารฉบับเต็มสำหรับหัวข้อเฉพาะ, และ svelte-autofixer เพื่อวิเคราะห์โค้ดและแนะนำการแก้ไข Autofixer รองรับ Svelte 4 และ 5 โดยกำหนดเป้าหมายผ่านแฟล็ก --svelte-version และโหมด async ผ่านแฟล็ก --async รองรับทั้งโค้ดแบบอินไลน์ (ที่มีอักขระ $ ที่ถูก Escape) และพาธไฟล์สำหรับการวิเคราะห์ ออกแบบมาเพื่อใช้ภายใน...
omni-embed
exploreomni
ฝังแดชบอร์ด Omni Analytics ในแอปพลิเคชันภายนอก — การเซ็น URL, ธีมที่กำหนดเอง, อีเวนต์ iframe, เวิร์กสเปซเอนทิตี และเนื้อหาที่รับรู้สิทธิ์ — โดยใช้…
sign-in-with-vercel
vercel
คำแนะนำการลงชื่อเข้าใช้ด้วย Vercel — ผู้ให้บริการระบุตัวตน OAuth 2.0/OIDC สำหรับการยืนยันตัวตนผู้ใช้ผ่านบัญชี Vercel ใช้เมื่อต้องการให้ผู้ใช้เข้าสู่ระบบด้วย Vercel ในฐานะ…
path-safety
microsoft
服务端路径安全与文件访问编码规范。在编写文件下载路由、Agent 工具(文件读取/目录列出)、数据连接器/Loader、Workspace 路径操作、沙箱配置时使用。
signals-scout-insight-alerts
posthog
สอดส่องสัญญาณผ่านการแจ้งเตือนเชิงลึกที่กำหนดค่าไว้ของโปรเจกต์เอง อ่านประวัติการยิงสัญญาณล่าสุดของแต่ละการแจ้งเตือน และจัดทำรายงานสำหรับการยิงสัญญาณที่มนุษย์อาจพลาดไป…