vitest

oleh antfu

Kerangka kerja pengujian unit cepat Vitest yang didukung oleh Vite dengan API yang kompatibel dengan Jest. Gunakan saat menulis pengujian, mocking, mengonfigurasi cakupan, atau bekerja dengan pemfilteran pengujian dan fixtures.

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 Terkait

using-kea-disposables
posthog
Use when adding timers (`setInterval`, `setTimeout`), event listeners (`window.addEventListener`, `document.addEventListener`,…
official
auth0-branding
auth0
Gunakan saat menyesuaikan tampilan Auth0 Universal Login agar sesuai dengan merek — mengubah warna, logo, font, tata letak halaman, atau teks login. Juga gunakan saat mereset…
official
building-streamlit-dashboards
streamlit
Membangun dasbor di Streamlit. Gunakan saat membuat tampilan KPI, kartu metrik, atau tata letak yang padat data. Mencakup batas, kartu, tata letak responsif, dan dasbor…
official
triaging-security-findings
bitwarden
Keahlian ini harus digunakan ketika pengguna meminta untuk "menyortir temuan keamanan", "memperbaiki temuan Checkmarx", "meninjau hasil SonarCloud", "menolak positif palsu",…
official
enable-shopify-markets
vercel
Aktifkan Shopify Markets dengan perutean multi-lokal menggunakan next-intl. Gunakan saat pengguna ingin menambahkan internasionalisasi, dukungan multi-lokal, prefiks lokal…
official
n8n-loops
n8n-io
Use when working with multi-item data, batches, paginated APIs, rate-limited APIs, fan-out across multiple branches, anything that needs to "do this for each",…
official
setup
microsoft
Siapkan prasyarat Power Automate CLI. Gunakan saat pengguna baru, ada sesuatu yang tidak berfungsi, atau mereka membutuhkan bantuan untuk memulai.
official
wp-playground
automattic
Gunakan untuk alur kerja WordPress Playground: instance WP cepat yang dapat dibuang di browser atau secara lokal melalui @wp-playground/cli (server, run-blueprint, build-snapshot),…
official