vitest

Guide Vitest test setup, async testing, mocking, snapshots, and performance optimization.

3|1|Updated Jun 3, 2025
One-click install
npx skills add https://github.com/Tobbe3108/GoPayShortcuts --skill vitest-tobbe3108
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: vitest
Source: https://github.com/Tobbe3108/GoPayShortcuts/tree/main/.opencode/skills/vitest
Command: npx skills add https://github.com/Tobbe3108/GoPayShortcuts --skill vitest-tobbe3108

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill provides a structured guide for Vitest usage, including best practices for test setup, asynchronous testing patterns, mocking with vi.*, snapshots, and performance optimizations to help teams write reliable and maintainable tests.

Core Features & Use Cases

  • Async testing guidance: ensure proper awaiting, waitFor usage, and rejection handling.
  • Test setup & isolation patterns: guidance on setup files, mocks, module resets, and state isolation.
  • Mocking patterns & MSW integration: recommended mocks strategies and when to use MSW for network calls.
  • Performance and snapshot practices: guidance to optimize test runs and stable snapshots.
  • Use Case: migrate Jest tests to Vitest with minimal friction.

Quick Start

Install Vitest in your project, configure a test script, and run tests with npx vitest run.

Frequently Asked Questions about vitest

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate Jest tests to Vitest with minimal friction?▼

To migrate Jest tests to Vitest, configure a test script using npx vitest run and apply Vitest patterns for test setup, mocking, and snapshots to transition smoothly.

What are the best practices for async testing in Vitest?▼

Vitest async testing best practices include ensuring proper awaiting, using waitFor for timing control, and handling rejections correctly to maintain reliable test execution.

How do I use vi.* mocking patterns and MSW integration in Vitest?▼

Vitest mocking with vi.* provides module and function mocking strategies, while MSW integration is recommended for mocking network calls to ensure test isolation and reliability.

Can I optimize Vitest performance and snapshot stability for CI?▼

Vitest performance optimization and stable snapshots are achieved by following test isolation patterns, module resets, and setup file configurations to ensure reliable CI runs.

What setup and isolation patterns should I use for Vitest test files?▼

Vitest test setup and isolation patterns involve configuring setup files, applying mocks, executing module resets, and maintaining state isolation to prevent test cross-contamination.