vitest

Write, configure, and run Vitest unit tests with mocking, coverage, and fixtures.

2|Updated Feb 15, 2026
One-click install
npx skills add https://github.com/SkinnnyJay/simpill-utils --skill vitest-skinnnyjay
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: vitest
Source: https://github.com/SkinnnyJay/simpill-utils/tree/main/.agents/skills/vitest
Command: npx skills add https://github.com/SkinnnyJay/simpill-utils --skill vitest-skinnnyjay

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Setting up and maintaining a fast, Jest-compatible test suite in a Vite-based project requires knowing many APIs, configuration options, and mocking patterns, which slows down test authoring and debugging. ## Core Features & Use Cases - Test Authoring: Use test, describe, expect, hooks, and parameterized tests with a Jest-compatible API and native TypeScript and ESM support. - Mocking & Snapshots: Mock functions, modules, timers, dates, globals, and environment variables with vi utilities, plus file and inline snapshot testing. - Coverage, Filtering & Projects: Configure V8 or Istanbul coverage thresholds, filter tests by name, tags, or changed files, and run multi-project workspaces with different environments. - Use Case: When adding tests to a Vite application, ask for a test suite that mocks an API module, uses fake timers, runs in jsdom, and enforces 80% coverage thresholds. ## Quick Start Write a Vitest test file for my utility module with mocked dependencies, jsdom environment, and coverage configuration.

Frequently Asked Questions about vitest

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

FAQPage Schema
How do I write unit tests with Vitest?▼

Import test and expect from vitest, define tests with test() or it(), and group them with describe(). Vitest supports async tests, parameterized tests via test.each or test.for, and modifiers like skip, only, todo, and concurrent.

How to mock modules and functions in Vitest?▼

Use vi.fn() for mock functions, vi.spyOn() for object methods, and vi.mock() for module mocking, which is hoisted before imports. For dynamic imports use vi.doMock(), and use vi.hoisted() to reference variables inside mock factories.

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

Vitest provides a Jest-compatible API, so most Jest test suites work as drop-in replacements. It adds native ESM, TypeScript, and JSX support without configuration and shares config, transformers, and plugins with your Vite app.

Does Vitest support code coverage reporting?▼

Yes, Vitest has built-in coverage via the V8 or Istanbul providers, enabled with the --coverage flag or coverage.enabled in config. It supports text, json, html, and lcov reporters plus line, branch, function, and statement thresholds.

How do I test browser DOM code with Vitest?▼

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

Why does vi.mock not work with my dynamic import?▼

vi.mock is hoisted to the top of the file, so it cannot intercept imports that happen later at runtime. Use vi.doMock() before the dynamic import and vi.doUnmock() afterward to restore the original module.