Use when writing unit/integration tests for Vite projects - configure vitest.config.ts, write test suites with describe/it, create mock implementations with vi.fn and vi.mock, set up code coverage thresholds, and run tests in parallel
Consider loading these reference files based on your task:
references/config.md - if setting up vitest.config.ts, CLI, or workspace projects
references/test-api.md - if writing test/describe blocks, using hooks, or test fixtures
references/mocking.md - if mocking modules, timers, dates, or using spies
references/utilities.md - if writing assertions, snapshots, or configuring coverage
references/advanced.md - if configuring test environments, type testing, or browser mode
DO NOT load all files at once. Load only what's relevant to your current task.
Cross-Skill References
Vue component testing → Use vue skill for component patterns
Library testing → Use ts-library skill for library patterns
Vite configuration → Use vite skill for shared config
1---2name: vitest-23description: Use when writing unit/integration tests for Vite projects - configure vitest.config.ts, write test suites with describe/it, create mock implementations with vi.fn and vi.mock, set up code coverage thresholds, and run tests in parallel4license: MIT5---67# Vitest89Vite-native testing framework with Jest-compatible API.1011## When to Use1213- Writing unit/integration tests for Vite projects14- Testing Vue/React/Svelte components15- Mocking modules, timers, or dates16- Running concurrent/parallel tests17- Type testing with TypeScript1819## Quick Start2021```bash22npm i -D vitest23```2425```ts26// vitest.config.ts27import { defineConfig } from 'vitest/config'2829export default defineConfig({30 test: {31 globals: true,32 environment: 'node', // or 'jsdom' for DOM tests33 },34})35```3637```ts38// example.test.ts39import { describe, expect, it, vi } from 'vitest'4041describe('math', () => {42 it('adds numbers', () => {43 expect(1 + 1).toBe(2)44 })45})46```4748## Reference Files4950| Task | File |51| ---------------------------------------- | --------------------------------------- |52| Configuration, CLI, projects | [config.md](references/config.md) |53| test/describe, hooks, fixtures | [test-api.md](references/test-api.md) |54| vi.fn, vi.mock, timers, spies | [mocking.md](references/mocking.md) |55| expect, snapshots, coverage, filtering | [utilities.md](references/utilities.md) |56| Environments, type testing, browser mode | [advanced.md](references/advanced.md) |5758## Loading Files5960**Consider loading these reference files based on your task:**6162- [ ] [references/config.md](references/config.md) - if setting up vitest.config.ts, CLI, or workspace projects63- [ ] [references/test-api.md](references/test-api.md) - if writing test/describe blocks, using hooks, or test fixtures64- [ ] [references/mocking.md](references/mocking.md) - if mocking modules, timers, dates, or using spies65- [ ] [references/utilities.md](references/utilities.md) - if writing assertions, snapshots, or configuring coverage66- [ ] [references/advanced.md](references/advanced.md) - if configuring test environments, type testing, or browser mode6768**DO NOT load all files at once.** Load only what's relevant to your current task.6970## Cross-Skill References7172- **Vue component testing** → Use `vue` skill for component patterns73- **Library testing** → Use `ts-library` skill for library patterns74- **Vite configuration** → Use `vite` skill for shared config
Run npx skillmds@latest add om-scogo/vitest-2 in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Use when writing unit/integration tests for Vite projects - configure vitest.config.ts, write test suites with describe/it, create mock implementations with vi.fn and vi.mock, set up code coverage thresholds, and run tests in parallel It is listed under Integrations & APIs on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free. This skill is licensed under MIT.
om-scogo (@om-scogo) published this skill. Their other Agent Skills are listed on their SkillMD profile.