vitest

Create and run unit and integration tests in Vite projects.

1|Updated Feb 10, 2026
One-click install
npx skills add https://github.com/fefogarcia/approved-skills --skill vitest-fefogarcia
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vitest
Source: https://github.com/fefogarcia/approved-skills/tree/main/skills/vitest
Command: npx skills add https://github.com/fefogarcia/approved-skills --skill vitest-fefogarcia

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill streamlines the process of writing and running unit and integration tests for projects using the Vite build tool, offering a faster and more modern alternative to Jest.

Core Features & Use Cases

  • Configuration: Supports various environments (Node, JSDOM, Workers) and setups (React, Cloudflare Workers).
  • Mocking: Provides powerful and type-safe mocking utilities like vi.mock, vi.spyOn, and vi.stubGlobal.
  • Snapshot Testing: Enables easy snapshot testing for component outputs and data structures.
  • In-Source Testing: Allows tests to be written directly within source files, tree-shaken in production.
  • Workspace Support: Facilitates monorepo configurations with vitest.workspace.ts.
  • Browser Mode: Enables testing directly in a browser environment using Playwright or WebDriverIO.
  • Coverage: Integrates with coverage tools for comprehensive code analysis.
  • Jest Migration: Offers clear guidance and patterns for migrating from Jest.

Quick Start

Configure your project by adding a vitest.config.ts file and running tests with pnpm test.

Frequently Asked Questions about vitest

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

FAQPage Schema
How do I migrate from Jest to Vitest in a Vite project?

Migrating from Jest to Vitest involves using the provided migration guidance and patterns to transition your existing test suite. Vitest offers a faster, modern alternative by natively integrating with the Vite build pipeline.

How do I configure unit and integration tests for different environments like Node or JSDOM?

Configuring tests for different environments requires defining the target environment in your configuration file. You can set up environments including Node, JSDOM, and Workers, with specific setups for frameworks like React or Cloudflare Workers.

Can I run browser-based testing using Playwright or WebDriverIO with Vitest?

Yes, you can run browser-based testing directly in a browser environment using Playwright or WebDriverIO. This enables executing tests within actual browser contexts to validate component behavior accurately.

Does Vitest support monorepo configurations for managing multiple projects?

Yes, Vitest supports monorepo configurations using a workspace file. This facilitates managing and running tests across multiple projects within a single repository structure efficiently.

What is the best way to mock modules and global variables in Vite tests?

The best way to mock modules and globals in Vite tests is using type-safe utilities like vi.mock, vi.spyOn, and vi.stubGlobal. These functions provide robust mocking capabilities for isolating components during unit and integration testing.

How does in-source testing work for tree-shaking test code in production?

In-source testing allows you to write tests directly within your source files, which are automatically tree-shaken and removed during production builds. This keeps implementation and validation logic co-located without impacting bundle size.