vitest_runner

Writes and runs Vitest unit, component, and integration tests with mocking and coverage.

Updated Jan 14, 2026
One-click install
npx skills add https://github.com/jvsandhu/agentic-skills --skill vitest-runner-jvsandhu
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vitest_runner
Source: https://github.com/jvsandhu/agentic-skills/tree/main/skills/vitest_runner
Command: npx skills add https://github.com/jvsandhu/agentic-skills --skill vitest-runner-jvsandhu

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Setting up and maintaining a reliable JavaScript/TypeScript test suite is time-consuming, and developers often struggle with mocking dependencies, handling async code, and measuring coverage correctly. ## Core Features & Use Cases - Test Authoring Patterns: Provides ready-to-use patterns for unit tests, async tests, error assertions, and snapshot testing with Vitest. - Mocking & Isolation: Guides module and function mocking with vi.mock() and vi.fn() to isolate the unit under test. - React Component Testing: Integrates Testing Library patterns for rendering components and simulating user events. - Coverage & Workflow: Covers a three-phase workflow from environment setup (jsdom/happy-dom/node) through coverage reporting with v8 or istanbul. - Use Case: When adding tests to a Vite-based React project, use this Skill to configure the test environment, mock API calls, write component interaction tests, and generate a coverage report. ## Quick Start Write Vitest unit tests with mocked API calls for my TypeScript utility functions and show me how to run them with coverage.

Frequently Asked Questions about vitest_runner

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

FAQPage Schema
How do I write unit tests with Vitest?

Import describe, it, and expect from vitest, then group assertions inside describe blocks. Use expect with matchers like toBe for primitives, toEqual for objects, and toThrow for error cases.

How to mock modules and functions in Vitest?

Use vi.mock('./module', factory) to replace an entire module's exports, and vi.fn() to create standalone mock functions. Verify calls with matchers like toHaveBeenCalledWith, and reset state between tests with vi.clearAllMocks().

Vitest vs Jest for testing JavaScript projects?

Vitest offers a Jest-compatible API while integrating natively with Vite configuration, so test settings stay synchronized with your build. It is the natural choice for Vite-based projects, while Jest remains common in older setups.

Does Vitest support React component testing?

Yes, Vitest works with @testing-library/react to render components and @testing-library/user-event to simulate interactions. Configure the jsdom or happy-dom environment in vitest.config.ts for DOM-based tests.

How do I measure test coverage in Vitest?

Enable coverage by selecting the v8 or istanbul provider in your Vitest configuration and running tests with the coverage flag. The generated report shows which lines and branches your tests exercise.

Why do my Vitest async tests fail or pass incorrectly?

Async tests fail silently when promises are not awaited. Always await expect(promise).rejects.toThrow() for rejections and await async calls inside it blocks so assertions run after resolution.