vitest
SKILL.md
Vitest Skill
Vitest is a blazing-fast unit test framework built on top of Vite. It shares the same config, transforms, and module resolution as your Vite project, giving you zero-config testing for most setups.
Quick Start
Minimum setup:
npm install -D vitest
// vitest.config.ts
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
environment: 'node',
},
})
First test (src/math.test.ts):
import { describe, it, expect } from 'vitest'
import { add } from './math'
describe('add', () => {
it('returns the sum of two numbers', () => {
expect(add(1, 2)).toBe(3)
})
})
npx vitest # watch mode
npx vitest run # single run (CI)
When This Skill Activates
- User asks to write a test for a function, component, or module
- User asks how to configure Vitest or integrate it into an existing Vite project
- User's tests are failing and they need help diagnosing the error
- User asks about mocking, spying, or stubbing in Vitest
- User wants to measure or enforce test coverage
Behavior Guidelines
- Prefer Vitest-native imports — import
describe,it,expect,vi, etc. from'vitest', not from@jest/*packages. - Respect the existing config — read
vitest.config.tsorvite.config.tsbefore suggesting configuration changes. - Match the project's test style — check existing test files for naming conventions (
*.test.tsvs*.spec.ts,itvstest) and follow them. - Use
vifor all mocking — never suggestjest.fn(),jest.mock(), etc. - Run tests to verify — after writing or modifying tests, suggest running
npx vitest runto confirm they pass.
References Loading Guide
Load additional context files based on what the user needs:
| Situation | Load |
|---|---|
Questions about vitest.config.ts, environments, globals, setupFiles |
references/config.md |
Questions about describe, it, test, expect, hooks |
references/api.md |
Questions about vi.fn(), vi.mock(), vi.spyOn(), timers, globals |
references/mocking.md |
Questions about coverage providers, thresholds, --coverage flag |
references/coverage.md |
Read only what is relevant to the current question. Do not preload all files unless the user's question spans multiple areas.
Weekly Installs
1
Repository
hamsurang/hamkitFirst Seen
Mar 1, 2026
Security Audits
Installed on
amp1
cline1
opencode1
cursor1
kimi-cli1
codex1