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.
npx claudepluginhub hamsurang/kit --plugin vitestThis skill uses the workspace's default tool permissions.
- [Quick Start](#quick-start)
Guides Vitest testing for TypeScript/JavaScript projects: installation, config, running tests with watch/UI/coverage, assertions, and mocking.
Provides Vitest patterns for unit/integration tests, vitest.config, vi.mock/vi.fn mocking, snapshots, coverage, assertions, and async testing.
Guides Vitest usage for unit testing in Vite apps: writing tests, mocking, coverage, CLI, filtering, fixtures, snapshots, and concurrency.
Share bugs, ideas, or general feedback.
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.