
Vitest Testing
- 724 installs
- 202 repo stars
- Updated August 4, 2026
- secondsky/claude-skills
vitest-testing is a Claude Code skill that generates, runs, and maintains Vitest test suites for TypeScript and JavaScript projects for developers who need fast Vite-powered unit and integration tests with native ESM sup
About
vitest-testing is a Testing & QA skill that equips coding agents with expert Vitest workflows for TypeScript and JavaScript codebases. The skill covers installation via Bun or npm, vitest.config.ts setup, native ESM support, Vite-powered hot module reload during test runs, and comprehensive mocking patterns. Allowed tools Bash, Read, Edit, Write, Grep, Glob, and TodoWrite let agents scaffold tests, execute suites, and fix failures in real repositories. Developers reach for vitest-testing when migrating from Jest, adding coverage to Vite apps, or maintaining fast unit and integration tests without spinning up a separate test runner stack.
- Generates comprehensive Vitest test files from component or function specifications
- Runs targeted test suites and interprets results within the agent workflow
- Supports test-driven development loops with instant feedback
- Maintains and updates existing test coverage as code evolves
- Integrates cleanly with TypeScript, Vite, and modern frontend stacks
Vitest Testing by the numbers
- 724 all-time installs (skills.sh)
- +62 installs in the week ending Aug 5, 2026 (Skillselion tracking)
- Ranked #569 of 2,153 Testing & QA skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/secondsky/claude-skills --skill vitest-testingAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 724 |
|---|---|
| repo stars | ★ 202 |
| Last updated | August 4, 2026 |
| Repository | secondsky/claude-skills ↗ |
How do you set up Vitest tests for a TypeScript project?
Generate, run, and maintain Vitest test suites for TypeScript and JavaScript projects directly through their coding agent.
Who is it for?
TypeScript or JavaScript developers on Vite-based projects who want agent-assisted Vitest authoring, execution, and maintenance.
Skip if: Teams standardized on Jest with heavy custom transformers, Python pytest workflows, or end-to-end-only Playwright suites without unit tests.
When should I use this skill?
A user mentions Vitest, unit tests, vitest.config.ts, ESM test setup, or mocking in a TS/JS Vite project.
What you get
vitest.config.ts, test spec files, mock utilities, and executed Vitest run results
- vitest.config.ts
- Test spec files
- Vitest run output
Files
Vitest Testing
Expert knowledge for testing JavaScript/TypeScript projects using Vitest - a blazingly fast testing framework powered by Vite.
Quick Start
Installation
# Using Bun (recommended)
bun add -d vitest
# Using npm
npm install -D vitestConfiguration
// vitest.config.ts
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
globals: true,
environment: 'node', // or 'jsdom'
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
thresholds: { lines: 80, functions: 80, branches: 80 },
},
include: ['**/*.{test,spec}.{js,ts,jsx,tsx}'],
},
})Running Tests
# Run all tests (prefer bun)
bun test
# Watch mode (default)
bun test --watch
# Run once (CI mode)
bun test --run
# With coverage
bun test --coverage
# Specific file
bun test src/utils/math.test.ts
# Pattern matching
bun test --grep="calculates sum"
# UI mode (interactive)
bun test --ui
# Verbose output
bun test --reporter=verboseWriting Tests
Basic Structure
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
import { add, subtract } from './math'
describe('Math utilities', () => {
beforeEach(() => {
// Setup before each test
})
it('adds two numbers correctly', () => {
expect(add(2, 3)).toBe(5)
})
it('subtracts two numbers correctly', () => {
expect(subtract(5, 3)).toBe(2)
})
})Parametrized Tests
describe.each([
{ input: 2, expected: 4 },
{ input: 3, expected: 9 },
])('square function', ({ input, expected }) => {
it(`squares ${input} to ${expected}`, () => {
expect(square(input)).toBe(expected)
})
})Assertions
// Equality
expect(value).toBe(expected)
expect(value).toEqual(expected)
// Truthiness
expect(value).toBeTruthy()
expect(value).toBeNull()
expect(value).toBeDefined()
// Numbers
expect(number).toBeGreaterThan(3)
expect(number).toBeCloseTo(0.3, 1)
// Strings/Arrays
expect(string).toMatch(/pattern/)
expect(array).toContain(item)
// Objects
expect(object).toHaveProperty('key')
expect(object).toMatchObject({ a: 1 })
// Exceptions
expect(() => throwError()).toThrow('message')
// Promises
await expect(promise).resolves.toBe(value)
await expect(promise).rejects.toThrow()Mocking
Function Mocks
import { vi } from 'vitest'
const mockFn = vi.fn()
mockFn.mockReturnValue(42)
mockFn.mockResolvedValue('async result')
mockFn.mockImplementation((x) => x * 2)
expect(mockFn).toHaveBeenCalled()
expect(mockFn).toHaveBeenCalledWith('arg')Module Mocking
vi.mock('./api', () => ({
fetchUser: vi.fn(() => ({ id: 1, name: 'Test User' })),
}))
import { fetchUser } from './api'
beforeEach(() => {
vi.clearAllMocks()
})Timers
beforeEach(() => vi.useFakeTimers())
afterEach(() => vi.restoreAllMocks())
it('advances timers', () => {
const callback = vi.fn()
setTimeout(callback, 1000)
vi.advanceTimersByTime(1000)
expect(callback).toHaveBeenCalledOnce()
})
it('mocks dates', () => {
const date = new Date('2024-01-01')
vi.setSystemTime(date)
expect(Date.now()).toBe(date.getTime())
})Coverage
# Generate coverage report
bun test --coverage
# HTML report
bun test --coverage --coverage.reporter=html
open coverage/index.html
# Check against thresholds
bun test --coverage --coverage.thresholds.lines=90Integration Testing
import request from 'supertest'
import { app } from './app'
describe('API endpoints', () => {
it('creates a user', async () => {
const response = await request(app)
.post('/api/users')
.send({ name: 'John' })
.expect(201)
expect(response.body).toMatchObject({
id: expect.any(Number),
name: 'John',
})
})
})Best Practices
- One test file per source file:
math.ts→math.test.ts - Group related tests with
describe()blocks - Use descriptive test names
- Mock only external dependencies
- Use
concurrenttests for independent async tests - Share expensive fixtures with
beforeAll() - Aim for 80%+ coverage but don't chase 100%
See Also
test-quality-analysis- Detecting test smellsplaywright-testing- E2E testingmutation-testing- Validate test effectiveness
Related skills
FAQ
Does vitest-testing support native ESM projects?
vitest-testing documents Vitest's native ESM support for modern TypeScript and JavaScript projects. Agents configure vitest.config.ts and write specs that run without legacy CommonJS-only workarounds.
Which package managers does vitest-testing document for install?
vitest-testing includes Bun as the recommended install path and npm as an alternative for adding vitest as a dev dependency before agents generate and run test suites.