vitest

Apply Vitest best practices to reduce flaky tests and optimize test pipelines.

Updated Jan 17, 2026
One-click install
npx skills add https://github.com/AndyMarigoldLabs/continuous-funding --skill vitest-andymarigoldlabs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vitest
Source: https://github.com/AndyMarigoldLabs/continuous-funding/tree/main/frontend/.claude/skills/vitest
Command: npx skills add https://github.com/AndyMarigoldLabs/continuous-funding --skill vitest-andymarigoldlabs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and assets (resource) components.

What problem does it solve?

Vitest Best Practices helps teams reduce flaky tests, improve test reliability, and optimize test performance by providing a structured, battle-tested set of rules and examples for Vitest users.

Core Features & Use Cases

  • Async patterns: guidance to properly await promises, use waitFor, and handle async errors.
  • Test setup & isolation: strategies for avoiding shared state, cleanup, and mock restoration.
  • Mocking patterns: best practices for vi.mock, vi.spyOn, MSW, and avoiding over-mocking.
  • Performance optimization: configuration tips such as pool type, environment, and run modes in CI.
  • Snapshot & environment patterns: maintainable snapshots and robust DOM environments.
  • Usage guidance: how to apply in PRs and CI, plus migration tips from Jest to Vitest.

Quick Start

Use the Vitest best practices skill to audit and refactor your test suite; start with the starter checklist in the README and dive into AGENTS.md for detailed guidance.

Frequently Asked Questions about vitest

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

FAQPage Schema
How do I fix flaky Vitest tests caused by shared state and async patterns?

Fix flaky Vitest tests by applying best practices for test isolation, properly awaiting promises, using waitFor, and handling async errors to ensure reliable test execution.

What is the best way to configure Vitest mocking with vi.mock and vi.spyOn?

The best way to configure Vitest mocking is using vi.mock and vi.spyOn strategically, avoiding over-mocking by relying on structured patterns and MSW for robust network interception.

How do I optimize Vitest performance for CI pipelines?

Optimize Vitest performance for CI by tuning configuration options such as pool types, selecting appropriate environments, and adjusting run modes to accelerate test pipeline execution.

How do I maintain reliable Vitest snapshots and DOM environments?

Maintain reliable Vitest snapshots by following structured update patterns and configuring robust DOM environments to prevent snapshot drift and ensure consistent UI test results.

Can I use this Vitest guidance to migrate an existing Jest test suite?

Yes, you can use this guidance to migrate Jest test suites, providing specific migration tips and structured refactoring rules to transition your tests to Vitest effectively.

Do I need extra software installations to apply these Vitest best practices?

No extra software installation is required; you only need a Node.js environment with Vitest available to start auditing and refactoring your test suite using these best practices.