From vitest
Writes, runs, debugs Vitest tests; configures vitest.config.ts or vite.config.ts; mocks with vi utility; sets up coverage and thresholds; diagnoses failures using Vitest API.
How this skill is triggered — by the user, by Claude, or both
Slash command
/vitest:vitestThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- [Quick Start](#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)
describe, it, expect, vi, etc. from 'vitest', not from @jest/* packages.vitest.config.ts or vite.config.ts before suggesting configuration changes.*.test.ts vs *.spec.ts, it vs test) and follow them.vi for all mocking — never suggest jest.fn(), jest.mock(), etc.npx vitest run to confirm they pass.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.
npx claudepluginhub hamsurang/kit --plugin vitestVitest testing framework conventions and practices. Invoke whenever task involves any interaction with Vitest — writing tests, configuring vitest.config.ts, mocking modules, debugging test failures, snapshots, coverage, or migrating from Jest.
Guides Vitest testing for TypeScript/JavaScript projects: installation, config, running tests with watch/UI/coverage, assertions, and mocking.
Configures and runs Vitest tests for JavaScript/TypeScript Vite projects. Covers setup, commands, mocking, coverage, snapshots, and Jest migration.