vitest
Fungsinya
Skill ini menjelaskan cara menulis dan menjalankan tes otomatis dengan Vitest, alat tes yang bekerja dengan proyek Vite. Skill ini untuk pengembang yang menginginkan tes cepat dengan gaya mirip Jest.
Kapan dipakai
- ✓Saat Anda perlu menulis tes unit untuk fungsi atau komponen.
- ✓Saat Anda ingin menambahkan mock, spy, atau snapshot test.
- ✓Saat Anda ingin mengatur coverage tes atau memilih tes mana yang dijalankan.
Link skill
https://github.com/antfu/skills/blob/main/skills/vitest/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
“Tulis tes unit Vitest untuk fungsi kalkulator harga saya, termasuk kasus-kasus tepinya.”
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent memakai fungsi test, describe, dan expect milik Vitest serta mengikuti konfigurasi proyek. Dalam mode watch, Vitest hanya menjalankan ulang tes yang terpengaruh oleh perubahan.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
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
| Topic | Description | Reference |
|---|---|---|
| Configuration | Vitest and Vite config integration, defineConfig usage | core-config |
| CLI | Command line interface, commands and options | core-cli |
| Test API | test/it function, modifiers like skip, only, concurrent | core-test-api |
| Describe API | describe/suite for grouping tests and nested suites | core-describe |
| Expect API | Assertions with toBe, toEqual, matchers and asymmetric matchers | core-expect |
| Hooks | beforeEach, afterEach, beforeAll, afterAll, aroundEach | core-hooks |
Features
| Topic | Description | Reference |
|---|---|---|
| Mocking | Mock functions, modules, timers, dates with vi utilities | features-mocking |
| Snapshots | Snapshot testing with toMatchSnapshot and inline snapshots | features-snapshots |
| Coverage | Code coverage with V8 or Istanbul providers | features-coverage |
| Test Context | Test fixtures, context.expect, test.extend for custom fixtures | features-context |
| Concurrency | Concurrent tests, parallel execution, sharding | features-concurrency |
| Filtering | Filter tests by name, file patterns, tags | features-filtering |
| Test Tags | Label tests with tags to filter runs and apply shared options | features-test-tags |
| Reporters | Built-in reporters, default selection, CI/output config | features-reporters |
| Benchmarking | Write benchmarks with the bench fixture (Tinybench) | features-benchmarking |
Advanced
| Topic | Description | Reference |
|---|---|---|
| Vi Utilities | vi helper: mock, spyOn, fake timers, hoisted, waitFor | advanced-vi |
| Environments | Test environments: node, jsdom, happy-dom, custom | advanced-environments |
| Type Testing | Type-level testing with expectTypeOf and assertType | advanced-type-testing |
| Projects | Multi-project workspaces, different configs per project | advanced-projects |
Pertanyaan umum
Apakah Vitest mirip Jest?
Ya. API-nya kompatibel dengan sebagian besar rangkaian tes Jest, sehingga banyak tes bisa dipindahkan dengan mudah.
Bisakah ia mengukur coverage tes?
Bisa. Coverage dapat dikumpulkan dengan V8 atau Istanbul.
Apakah perlu pengaturan tambahan untuk TypeScript?
Tidak. TypeScript, ES module, dan JSX berfungsi tanpa konfigurasi tambahan.
Detail
Deskripsi asli dari pembuat
Vitest fast unit testing framework powered by Vite with Jest-compatible API. Use when writing tests, mocking, configuring coverage, or working with test filtering and fixtures.
repo: antfu/skills
Popularitas
- Bintang GitHub
- 6.0k
- Peringkat
- #14447
- Lisensi
- MIT
- Diperbarui
- 30/10/2026
Komentar
- …
Skill lain dari repositori ini
antfu-create-pr
6.0kMembantu agent Anda membuka pull request GitHub yang jelas dari cabang Anda, dengan ringkasan sederhana tentang apa yang berubah dan mengapa.
antfu-issue-triage
6.0kMembantu agent Anda memilah isu dan pull request GitHub yang terbuka, menemukan duplikat dan yang sudah diperbaiki, lalu bertanya kepada Anda sebelum bertindak.
antfu-query
6.0kMembantu agent Anda bertanya kepada Anda satu per satu tentang sebuah rencana atau ide, hingga keduanya sepakat pada pemahaman yang jelas.
antfu-simplify
6.0kMembantu agent Anda memangkas perubahan kode menjadi versi terkecil yang tetap benar, dengan membuang bagian yang tidak diperlukan.
Skill serupa
test-driven-development
311kMengajari agent Anda menulis tes yang gagal dulu, melihatnya gagal, lalu menulis kode terkecil yang lulus, sebelum membangun fitur atau perbaikan apa pun.
verification-before-completion
311kMengajari agent Anda menjalankan pemeriksaan nyata dan membaca keluarannya sebelum menyatakan tugas, perbaikan, atau build sudah selesai atau lulus.
migrate-to-shoehorn
310kMengganti type cast berisiko di file tes Anda dengan pustaka shoehorn, sehingga tes bisa memakai data parsial dan tetap lulus pemeriksaan tipe.