Full-stack-skills vitest
Provides comprehensive guidance for Vitest testing framework including fast test execution, Vite integration, component testing, mocking, and configuration. Use when the user asks about Vitest, needs to write fast unit tests, test Vue/React components, or configure Vitest with Vite projects.
git clone https://github.com/partme-ai/full-stack-skills
T=$(mktemp -d) && git clone --depth=1 https://github.com/partme-ai/full-stack-skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/testing-skills/vitest" ~/.claude/skills/partme-ai-full-stack-skills-vitest && rm -rf "$T"
skills/testing-skills/vitest/SKILL.mdWhen to use this skill
Use this skill whenever the user wants to:
- Set up Vitest in a Vite project
- Write unit tests and component tests
- Configure Vitest for different environments
- Use Vitest API and utilities
- Test Vue, React, or Svelte components
- Use browser mode for testing
- Set up visual regression testing
- Mock functions and modules
- Use snapshots for testing
- Configure test coverage
- Use Vitest UI
- Optimize test performance
- Debug tests
- Understand Vitest best practices
- Troubleshoot Vitest issues
How to use this skill
This skill is organized to match the Vitest official documentation structure (https://vitest.dev/guide/, https://vitest.dev/api/, https://vitest.dev/config/). When working with Vitest:
-
Identify the topic from the user's request:
- Getting started/快速开始 →
examples/getting-started.md - Features/功能特性 →
examples/features.md - Component testing/组件测试 →
examples/component-testing.md - Browser mode/浏览器模式 →
examples/browser-mode.md - API/API 文档 →
api/ - Configuration/配置 →
examples/config/
- Getting started/快速开始 →
-
Load the appropriate example file from the
directory:examples/Getting Started (快速开始):
- Installation and first testexamples/getting-started.md
Features (功能特性):
- Key features and capabilitiesexamples/features.md
- Vitest UIexamples/ui.md
- Component testingexamples/component-testing.md
- Browser mode testingexamples/browser-mode.md
- Visual regression testingexamples/visual-regression-testing.md
- Trace viewexamples/trace-view.md
Testing (测试):
- Test API (test, it, describe, etc.)examples/test-api.md
- Mocking functions and modulesexamples/mocking.md
- Snapshot testingexamples/snapshots.md
- Code coverageexamples/coverage.md
Configuration (配置):
- Basic configurationexamples/config/basic-config.md
- Environment configurationexamples/config/environment.md
- Browser mode configurationexamples/config/browser-config.md
-
Follow the specific instructions in that example file for syntax, structure, and best practices
Important Notes:
- Vitest is designed for Vite projects
- Supports TypeScript, JSX, ESM out of the box
- Fast watch mode with HMR-like experience
- Compatible with Jest API
- Examples include both JavaScript and TypeScript versions
- Each example file includes key concepts, code examples, and key points
-
Reference API documentation in the
directory when needed:api/
- Test API referenceapi/test-api.md
- vi utility functionsapi/vi-utility.md
- Expect assertionsapi/expect.md
- Mocking APIapi/mocking.md
-
Use templates from the
directory:templates/
- Vitest configuration templatestemplates/vitest-config.md
- Test example templatestemplates/test-examples.md
Doc mapping (one-to-one with https://vitest.dev/guide/, https://vitest.dev/api/, https://vitest.dev/config/)
Guide (指南):
→ https://vitest.dev/guide/getting-started.htmlexamples/getting-started.md
→ https://vitest.dev/guide/features.htmlexamples/features.md
→ https://vitest.dev/guide/ui.htmlexamples/ui.md
→ https://vitest.dev/guide/testing-components.htmlexamples/component-testing.md
→ https://vitest.dev/guide/browser.htmlexamples/browser-mode.md
→ https://vitest.dev/guide/visual-regression.htmlexamples/visual-regression-testing.md
→ https://vitest.dev/guide/trace-view.htmlexamples/trace-view.md
→ https://vitest.dev/guide/mocking.htmlexamples/mocking.md
→ https://vitest.dev/guide/snapshot.htmlexamples/snapshots.md
→ https://vitest.dev/guide/coverage.htmlexamples/coverage.md
Configuration (配置):
→ https://vitest.dev/config/examples/config/basic-config.md
→ https://vitest.dev/config/#environmentexamples/config/environment.md
→ https://vitest.dev/config/#browserexamples/config/browser-config.md
API Reference:
→ https://vitest.dev/api/api/test-api.md
→ https://vitest.dev/api/vi.htmlapi/vi-utility.md
→ https://vitest.dev/api/expect.htmlapi/expect.md
→ https://vitest.dev/api/vi.htmlapi/mocking.md
Examples and Templates
This skill includes detailed examples organized to match the official documentation structure. All examples are in the
examples/ directory (see mapping above).
To use examples:
- Identify the topic from the user's request
- Load the appropriate example file from the mapping above
- Follow the instructions, syntax, and best practices in that file
- Adapt the code examples to your specific use case
To use templates:
- Reference templates in
directory for common scaffoldingtemplates/ - Adapt templates to your specific needs and coding style
Best Practices
- Use watch mode: Leverage Vitest's smart watch mode for faster feedback
- Organize tests: Group related tests with describe blocks
- Use TypeScript: Take advantage of native TypeScript support
- Mock effectively: Use vi.mock() for module mocking
- Test components: Use component testing for Vue/React components
- Use UI mode: Use
flag for better test debugging experience--ui - Optimize performance: Use test.only() during development
Resources
- Official Documentation: https://vitest.dev/
- Getting Started: https://vitest.dev/guide/
- API Reference: https://vitest.dev/api/
- Configuration: https://vitest.dev/config/
- GitHub Repository: https://github.com/vitest-dev/vitest
Keywords
Vitest, vitest, test framework, unit testing, component testing, Vite, Jest compatible, watch mode, HMR, TypeScript, ESM, mocking, snapshots, coverage, browser mode, visual regression testing, 测试框架, 单元测试, 组件测试, 监视模式, 热模块替换, 模拟, 快照, 覆盖率, 浏览器模式, 视觉回归测试