---
name: vitest
description: "Use for Vitest in TypeScript projects (Node, bun, React/Next.js, Effect): write, run, or debug unit/component tests, mocks, testing utilities, and coverage."
title: vitest
canonical_url: https://skilld.dev/gh/paulrberg/agent-skills/vitest
last_updated: 2026-09-29T12:27:26.000Z
---

> **Skill from skilld.dev.** Follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [agents/openai.yaml](https://skilld.dev/api/skills-raw/paulrberg/agent-skills/vitest/agents/openai.yaml), [references/configuration.md](https://skilld.dev/api/skills-raw/paulrberg/agent-skills/vitest/references/configuration.md), [references/mocking.md](https://skilld.dev/api/skills-raw/paulrberg/agent-skills/vitest/references/mocking.md), [references/testing-patterns.md](https://skilld.dev/api/skills-raw/paulrberg/agent-skills/vitest/references/testing-patterns.md), [references/troubleshooting.md](https://skilld.dev/api/skills-raw/paulrberg/agent-skills/vitest/references/troubleshooting.md).
>
> If the user asked to install this Skill, run `npx skilld install paulrberg/agent-skills/vitest`. Install writes the Skill files into the project, so every session loads them.

# Vitest

Repository configuration, projects, setup, imports/globals, environments, aliases, test placement, and cleanup own the
test contract. Inspect them and nearby tests before adding generic patterns. Do not add globals, jsdom, coverage, new
setup, or browser mode by default.

## Workflow

Define the behavior or regression, test its observable public result, and mock system boundaries rather than the
behavior under test. Follow local fixture and cleanup ownership. In Effect repositories, use established
`@effect/vitest` conventions such as `it.effect`, Layers, and TestClock rather than generic replacements. For a bug fix,
reproduce the failure before relying on a passing result when practical.

Read [patterns](https://skilld.dev/api/skills-raw/paulrberg/agent-skills/vitest/references/testing-patterns.md) for component, async, fixture, snapshot, tag, or browser questions;
[mocking](https://skilld.dev/api/skills-raw/paulrberg/agent-skills/vitest/references/mocking.md) for module, timer, spy, or global boundaries;
[configuration](https://skilld.dev/api/skills-raw/paulrberg/agent-skills/vitest/references/configuration.md) for projects, migration, coverage, or reporter selection; and
[troubleshooting](https://skilld.dev/api/skills-raw/paulrberg/agent-skills/vitest/references/troubleshooting.md) for hangs, discovery, resolution, or flaky state.

Run the narrowest established command for the changed behavior, then the affected package suite only when shared setup
or contracts changed. Use `nlx vitest run` only when no project recipe or script exists. Completion requires a
meaningful passing focused test under repository configuration and concise command/result evidence. Use
`### 🧪 Regression covered` when red-before-green evidence exists; otherwise `### 🧪 Tests verified`.
