vitest

Write, run, and configure Vitest unit tests with Vite-native tooling.

Updated Sep 17, 2026
One-click install
npx skills add https://github.com/juanjaragavi/utilities-manager --skill vitest-juanjaragavi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: vitest
Source: https://github.com/juanjaragavi/utilities-manager/tree/main/.agents/skills/vitest
Command: npx skills add https://github.com/juanjaragavi/utilities-manager --skill vitest-juanjaragavi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Setting up and maintaining a fast JavaScript/TypeScript test suite requires deep knowledge of Vitest's configuration, mocking APIs, coverage providers, and version-specific breaking changes, which slows down developers writing reliable tests. ## Core Features & Use Cases - Test Authoring: Guidance for the test/describe/expect APIs, hooks, parameterized tests, fixtures via test.extend, and concurrent execution. - Mocking & Utilities: Module mocking with vi.mock, spies, fake timers, conditional mocking with vi.when, and environment stubbing. - Configuration & Tooling: Coverage with V8 or Istanbul, multi-project workspaces, test environments (jsdom, happy-dom), CLI filtering, sharding, and reporters. - Use Case: When migrating a Jest suite to Vitest 5, use this Skill to update config (projects instead of workspace, maxWorkers instead of poolOptions), rewrite benchmarks as test-context fixtures, and fix removed APIs like describe.sequential. ## Quick Start Use the vitest skill to write a test file with mocked API calls and coverage configuration for my TypeScript project.

Frequently Asked Questions about vitest

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

FAQPage Schema
How do I configure Vitest with an existing Vite config?▼

Add a test property to your vite.config.ts with a /// <reference types="vitest/config" /> directive, or create a separate vitest.config.ts which takes priority. Use mergeConfig from vitest/config to combine separate config files.

How do I mock a module in Vitest?▼

Use vi.mock with a factory function, which is hoisted above imports. For partial mocks, spread the result of importOriginal; use { spy: true } to keep real implementations while tracking calls, and vi.doMock for non-hoisted dynamic mocking.

Vitest vs Jest: can I migrate my existing test suite?▼

Vitest provides a Jest-compatible API covering test, describe, expect, and mocking, so most suites migrate with minimal changes. It adds native ESM and TypeScript support and shares your Vite config, transformers, and plugins.

Does Vitest support code coverage reporting?▼

Yes, Vitest supports coverage via the V8 provider (default, faster) or Istanbul (more compatible), enabled with the --coverage flag or coverage.enabled config. In v4 you must set coverage.include to report uncovered files, since coverage.all was removed.

Why did my Vitest config break after upgrading to v4 or v5?▼

Vitest v4 removed poolOptions (use top-level maxWorkers), the workspace option (use projects), and coverage.all; v5 removed test.sequential and describe.sequential (use { concurrent: false }) and made bench a test-context fixture instead of a top-level import.

How do I run tests in a browser-like environment with Vitest?▼

Set test.environment to jsdom or happy-dom in your config, or add a // @vitest-environment jsdom comment at the top of a file. For real browser testing, use Vitest Browser Mode with the Playwright provider.