Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
laurigates avatar

Vitest Testing

  • 85 installs
  • 49 repo stars
  • Updated August 4, 2026
  • laurigates/claude-plugins

Helps with testing & qa tasks.

About

vitest-testing is a Claude Code skill for testing & qa. It helps solo builders move faster with AI-assisted development.

  • vitest-testing
  • Testing & QA
  • AI-coding skill

Vitest Testing by the numbers

  • 85 all-time installs (skills.sh)
  • +5 installs in the week ending Aug 2, 2026 (Skillselion tracking)
  • Ranked #1,054 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/laurigates/claude-plugins --skill vitest-testing

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs85
repo stars49
Last updatedAugust 4, 2026
Repositorylaurigates/claude-plugins

What it does

Helps with testing & qa tasks.

Files

SKILL.mdMarkdownGitHub ↗

Vitest Testing

Vitest is a modern test runner designed for Vite projects. It's fast, ESM-native, and provides a Jest-compatible API with better TypeScript support and instant HMR-powered watch mode.

When to Use This Skill

Use this skill when...Use another skill instead when...
Setting up or configuring VitestWriting E2E browser tests (use playwright-testing)
Writing unit/integration tests in TS/JSTesting Python code (use python-testing)
Migrating from Jest to VitestAnalyzing test quality (use test-quality-analysis)
Configuring coverage thresholdsGenerating property-based tests (use property-based-testing)
Using mocks, spies, or fake timersValidating test effectiveness (use mutation-testing)

Core Expertise

  • Vite-native: Reuses Vite config, transforms, and plugins
  • Fast: Instant feedback with HMR-powered watch mode
  • Jest-compatible: Drop-in replacement with similar API
  • TypeScript: First-class TypeScript support
  • ESM: Native ESM support, no transpilation needed

Installation

bun add --dev vitest
bun add --dev @vitest/coverage-v8      # Coverage (recommended)
bun add --dev happy-dom                # DOM testing (optional)
bunx vitest --version                  # Verify

Configuration (vitest.config.ts)

import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    globals: true,
    environment: 'node',
  },
});

Essential Commands

bunx vitest                            # Watch mode (default)
bunx vitest run                        # Run once (CI mode)
bunx vitest --coverage                 # With coverage
bunx vitest src/utils.test.ts          # Specific file
bunx vitest -t "should add numbers"    # Filter by name
bunx vitest related src/utils.ts       # Related tests
bunx vitest -u                         # Update snapshots
bunx vitest bench                      # Benchmarks
bunx vitest --ui                       # UI mode

Writing Tests

Basic Test Structure

import { describe, it, expect } from 'vitest';
import { add, multiply } from './math';

describe('math utils', () => {
  it('should add two numbers', () => {
    expect(add(2, 3)).toBe(5);
  });

  it('should multiply two numbers', () => {
    expect(multiply(2, 3)).toBe(6);
  });
});

Key Assertions

AssertionDescription
toBe(value)Strict equality
toEqual(value)Deep equality
toStrictEqual(value)Deep strict equality
toBeTruthy() / toBeFalsy()Truthiness
toBeNull() / toBeUndefined()Null checks
toBeGreaterThan(n) / toBeLessThan(n)Numeric comparison
toBeCloseTo(n)Float comparison
toMatch(regex) / toContain(str)String matching
toHaveLength(n)Array/string length
toHaveProperty(key)Object property
toMatchObject(obj)Partial object match
toThrow(msg)Error throwing

Async Tests

test('async test', async () => {
  const data = await fetchData();
  expect(data).toBe('expected');
});

test('promise resolves', async () => {
  await expect(fetchData()).resolves.toBe('expected');
});

test('promise rejects', async () => {
  await expect(fetchBadData()).rejects.toThrow('error');
});

Mocking (Essential Patterns)

import { vi, test, expect } from 'vitest';

// Mock function
const mockFn = vi.fn();
mockFn.mockReturnValue(42);

// Mock module
vi.mock('./api', () => ({
  fetchUser: vi.fn(() => Promise.resolve({ id: 1, name: 'John' })),
}));

// Mock timers
vi.useFakeTimers();
vi.advanceTimersByTime(1000);
vi.restoreAllMocks();

// Spy on method
const spy = vi.spyOn(object, 'method');

Snapshot Testing

test('snapshot test', () => {
  expect(data).toMatchSnapshot();
});

test('inline snapshot', () => {
  expect(result).toMatchInlineSnapshot('5');
});
// Update snapshots: bunx vitest -u

Coverage

bun add --dev @vitest/coverage-v8
bunx vitest --coverage

Key config options: provider, reporter, include, exclude, thresholds.

Agentic Optimizations

ContextCommand
Quick testbunx vitest --reporter=dot --bail=1
CI testbunx vitest run --reporter=junit
Coverage checkbunx vitest --coverage --reporter=dot
Single filebunx vitest run src/utils.test.ts --reporter=dot
Failed onlybunx vitest --changed --bail=1

For detailed examples, advanced patterns, and best practices, see REFERENCE.md.

References

  • Official docs: https://vitest.dev
  • Configuration: https://vitest.dev/config/
  • API reference: https://vitest.dev/api/
  • Migration from Jest: https://vitest.dev/guide/migration.html
  • Coverage: https://vitest.dev/guide/coverage.html

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.