vitest

Run Jest-compatible unit tests for Vite-based projects with mocks, snapshots, and coverage.

Updated Jan 29, 2026
One-click install
npx skills add https://github.com/peterWang123589/rubin_forum --skill vitest-peterwang123589
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vitest
Source: https://github.com/peterWang123589/rubin_forum/tree/main/.opencode/skills/vitest
Command: npx skills add https://github.com/peterWang123589/rubin_forum --skill vitest-peterwang123589

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Vitest provides a fast, integrated testing experience for Vite-based projects, delivering a Jest-compatible API with native ESM support, fast transforms, and built-in coverage.

Core Features & Use Cases

  • Vite-native: leverages Vite's transformation pipeline for quick feedback.
  • Jest-compatible: drop-in replacement for most Jest test suites in modern apps.
  • Smart watch mode: only reruns affected tests based on module graph.
  • Snapshots, mocks, and coverage: built-in features for robust testing.
  • Cross-ecosystem compatibility: works with TypeScript, JSX, and modern frameworks.

Quick Start

Set up Vitest in your project by installing vitest and adding a vitest.config.ts; place tests under tests/ and run vitest.

Frequently Asked Questions about vitest

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

FAQPage Schema
How do I set up unit testing for a Vite project?

Unit testing for Vite uses Vitest to leverage Vite's transformation pipeline, providing fast transforms and native ESM support without duplicating configuration.

Can I use Vitest as a drop-in replacement for Jest in TypeScript?

Yes, Vitest provides a Jest-compatible API, allowing most TypeScript test suites to migrate with minimal changes while gaining native ESM support and faster execution.

Does Vitest support snapshots and mocks for React and Vue codebases?

Yes, Vitest provides built-in snapshot and mock features that work across React, Vue, Svelte, and TypeScript codebases for robust unit testing.

What is the best way to run only affected tests during development?

The best way is using Vitest's smart watch mode, which analyzes the module graph to only rerun affected tests, providing rapid feedback during active development.

Do I need a specific Node environment to run Vite unit tests with Vitest?

Yes, a Node environment with npm or yarn is required to install vitest, integrate it with Vite, and execute your unit test suites locally.