vitest

Run Jest-compatible unit and integration tests for Vite projects.

2|Updated May 5, 2023
One-click install
npx skills add https://github.com/baicie/template-repo --skill vitest-baicie
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vitest
Source: https://github.com/baicie/template-repo/tree/main/monorepo/.agents/skills/vitest
Command: npx skills add https://github.com/baicie/template-repo --skill vitest-baicie

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Vitest provides a fast, Jest-compatible testing framework for Vite projects, simplifying test setup, execution, and parallel workflow across modern frontend stacks.

Core Features & Use Cases

  • Unit and integration testing for Vite-based projects
  • Mocking with vi.fn and vi.mock, timers, and coverage thresholds
  • Parallel test execution and browser/environment support (node/jsdom)

Quick Start

Install Vitest in your project and start writing tests with describe/it, using vi.fn and vi.mock for mocks.

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?

Vitest provides a fast, Jest-compatible testing framework for Vite projects. It uses your existing vite.config.ts or vitest.config.ts for setup and allows you to write tests using familiar describe and it blocks.

Can I use Vitest for testing Vue, React, and Svelte components?

Vitest supports unit and integration testing across Vue, React, and Svelte components. It leverages the Vite pipeline to process and test these frontend components efficiently.

How do I create mocks and control timers in Vitest?

You can create mocks and control timers in Vitest using the built-in vi.fn and vi.mock utilities. These tools allow you to mock dependencies and manipulate timers for isolated unit testing.

Does Vitest support parallel test execution and code coverage?

Vitest supports parallel test execution and code coverage thresholds. It executes tests concurrently to maximize speed and provides built-in coverage reporting for your Vite project.

What is the best way to migrate from Jest to Vitest?

Migrating from Jest to Vitest is straightforward because Vitest provides a Jest-compatible API. You can transition your tests to Vite's pipeline for faster execution without major rewrites.

Do I need a specific configuration file to run Vitest?

Vitest requires a vitest.config.ts or vite.config.ts file to run. The framework uses frontmatter for test discovery and relies on this configuration to define environments like node or jsdom.