vitest

Write Vitest v4 tests for TypeScript React/Next.js projects.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing and maintaining tests for TypeScript React/Next.js projects can be error-prone without a cohesive testing strategy. This skill provides a concise, practical guide to using Vitest v4 for unit tests, component tests, and testing utilities, helping teams ship reliable code.

Core Features & Use Cases

  • Vitest v4 setup guidance for TypeScript projects using React/Next.js with a jsdom environment and global test APIs.
  • Practical patterns for unit tests, component tests, mocks, spies, and asynchronous testing, including debugging failing tests.
  • Best practices for test organization, isolation, and usage in monorepos or multi-app repositories.

Quick Start

Install Vitest in your project, configure the test environment, and start running tests with straightforward commands such as nlx vitest run and nlx vitest.

Frequently Asked Questions about vitest

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

FAQPage Schema
How do I set up Vitest for a TypeScript React and Next.js project?

Run tests in a TypeScript React or Next.js project using the `nlx vitest run` or `nlx vitest` commands. This executes your unit tests and component tests configured within a jsdom environment using global test APIs.

What is the best way to mock dependencies in Vitest for React components?

Vitest supports practical patterns for mocks, spies, and asynchronous testing in TypeScript React applications. These patterns allow you to isolate components, simulate API calls, and debug failing tests within your Next.js environment.

Does this Vitest skill support testing in monorepos or multi-app repositories?

Yes, this Vitest skill supports testing in monorepos and multi-app repositories. It provides best practices for test organization and isolation to maintain reliable unit tests and component tests across multiple TypeScript React applications.

Why are my Vitest unit tests failing in a jsdom environment?

Failing Vitest unit tests in a jsdom environment often stem from improper mocks or asynchronous testing issues. This skill provides debugging patterns for spies and component tests to resolve failures in TypeScript React projects.