Agent skill

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.

Stars 254
Forks 41

Install this agent skill to your Project

npx add-skill https://github.com/partme-ai/full-stack-skills/tree/main/skills/testing-skills/vitest

SKILL.md

When 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:

  1. 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/
  2. Load the appropriate example file from the examples/ directory:

    Getting Started (快速开始):

    • examples/getting-started.md - Installation and first test

    Features (功能特性):

    • examples/features.md - Key features and capabilities
    • examples/ui.md - Vitest UI
    • examples/component-testing.md - Component testing
    • examples/browser-mode.md - Browser mode testing
    • examples/visual-regression-testing.md - Visual regression testing
    • examples/trace-view.md - Trace view

    Testing (测试):

    • examples/test-api.md - Test API (test, it, describe, etc.)
    • examples/mocking.md - Mocking functions and modules
    • examples/snapshots.md - Snapshot testing
    • examples/coverage.md - Code coverage

    Configuration (配置):

    • examples/config/basic-config.md - Basic configuration
    • examples/config/environment.md - Environment configuration
    • examples/config/browser-config.md - Browser mode configuration
  3. 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
  4. Reference API documentation in the api/ directory when needed:

    • api/test-api.md - Test API reference
    • api/vi-utility.md - vi utility functions
    • api/expect.md - Expect assertions
    • api/mocking.md - Mocking API
  5. Use templates from the templates/ directory:

    • templates/vitest-config.md - Vitest configuration templates
    • templates/test-examples.md - Test example templates

Doc mapping (one-to-one with https://vitest.dev/guide/, https://vitest.dev/api/, https://vitest.dev/config/)

Guide (指南):

Configuration (配置):

API Reference:

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 templates/ directory for common scaffolding
  • Adapt templates to your specific needs and coding style

Best Practices

  1. Use watch mode: Leverage Vitest's smart watch mode for faster feedback
  2. Organize tests: Group related tests with describe blocks
  3. Use TypeScript: Take advantage of native TypeScript support
  4. Mock effectively: Use vi.mock() for module mocking
  5. Test components: Use component testing for Vue/React components
  6. Use UI mode: Use --ui flag for better test debugging experience
  7. Optimize performance: Use test.only() during development

Resources

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, 测试框架, 单元测试, 组件测试, 监视模式, 热模块替换, 模拟, 快照, 覆盖率, 浏览器模式, 视觉回归测试

Expand your agent's capabilities with these related and highly-rated skills.

partme-ai/full-stack-skills

ocrmypdf-batch

OCRmyPDF batch processing skill — process multiple PDFs, Docker automation, shell scripting, and CI/CD integration. Use when the user needs to OCR many PDFs, set up automated OCR pipelines, or integrate OCR into workflows.

254 41
Explore
partme-ai/full-stack-skills

ocrmypdf-optimize

OCRmyPDF optimization skill — compress PDFs, configure PDF/A output, JBIG2 encoding, and lossless optimization. Use when the user needs to reduce PDF file size, create archival PDF/A files, or optimize OCR output.

254 41
Explore
partme-ai/full-stack-skills

ocrmypdf-image

OCRmyPDF image processing skill — deskew, rotate, clean, despeckle, remove border from scanned documents. Use when the user needs to improve scanned PDF quality, fix skewed pages, remove noise, or clean up scanned documents before OCR.

254 41
Explore
partme-ai/full-stack-skills

ocrmypdf-api

OCRmyPDF Python API and plugin skill — use OCRmyPDF programmatically from Python, integrate with applications, and extend with plugins (EasyOCR, PaddleOCR, AppleOCR). Use when the user needs to call OCRmyPDF from Python code, build OCR pipelines, or use alternative OCR engines.

254 41
Explore
partme-ai/full-stack-skills

ocrmypdf

OCRmyPDF core skill — add searchable OCR text layer to scanned PDFs, convert images to searchable PDFs, support 100+ languages via Tesseract. Use when the user needs to OCR a PDF, make a scanned PDF searchable, or extract text from scanned documents.

254 41
Explore
partme-ai/full-stack-skills

svelte

Guides Svelte and SvelteKit development including reactive components, stores, transitions, lifecycle hooks, SSR, file-based routing, and deployment. Use when the user needs to build Svelte components, create SvelteKit applications, implement reactivity patterns, or configure Svelte with Vite.

254 41
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results