vitest

vitest is a skill for Claude Code, Codex from PyModel/react-frontend-skills. It costs 12 tokens per session (1,279 once invoked), scanned A, original, MIT.

A guide to using Vitest 4, a JavaScript and TypeScript test framework, for writing and maintaining automated tests. It covers test setup, asynchronous tests, mocks, snapshots, environments, assertions, and performance.

In plain words
What is it for?
Use it when writing or debugging Vitest tests, configuring test projects, reviewing changes, investigating flaky or slow tests, or improving test performance in continuous integration.
Why use it?
It helps avoid common testing mistakes, such as incorrect handling of asynchronous code, shared test state, or slow test runs. It also provides guidance for reviewing tests and moving from Jest to Vitest.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when writing or debugging Vitest tests, configuring test projects, reviewing changes, investigating flaky or slow tests, or improving test performance in continuous integration.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/pymodel/react-frontend-skills/vitest
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add PyModel/react-frontend-skills --skill vitest
Clone the repo
git clone --depth 1 https://github.com/PyModel/react-frontend-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for vitest

README.md
[![agentmods](https://agentmods.dev/badge/skills/pymodel/react-frontend-skills/vitest/github.svg)](https://agentmods.dev/skills/pymodel/react-frontend-skills/vitest)
Your own site
<a href="https://agentmods.dev/skills/pymodel/react-frontend-skills/vitest"><img src="https://agentmods.dev/badge/skills/pymodel/react-frontend-skills/vitest/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for vitest

Your own site · 80×15
<a href="https://agentmods.dev/skills/pymodel/react-frontend-skills/vitest"><img src="https://agentmods.dev/badge/skills/pymodel/react-frontend-skills/vitest.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 12 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,279 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00012 $0.01279
Opus 5.5 $0.00005 $0.00512
Sonnet 5.5 $0.00002 $0.00256
Haiku 4.5 $0.00001 $0.00128

Measured 22d ago against content hash 0ddeeb701b17, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

vitest scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 22d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/vitest/SKILL.md · 123 lines

How it starts

The opening of the file, as written. The whole thing — 123 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Vitest Best Practices

Vitest 5-compatible testing guide with 46 rules across 8 categories. Vitest 5 requires Node.js 22.12+ and Vite 6.4+; Vitest 4.1 remains on backport support.

When to Apply

Reference these guidelines when:

  • Writing new Vitest tests
  • Debugging flaky or slow tests
  • Setting up test configuration
  • Reviewing test code in PRs
  • Migrating from Jest to Vitest
  • Optimizing CI/CD test performance

Jest-specific APIs and configuration outside documented migration differences are out of scope; use Jest's own documentation for tests that still run under Jest.

Rule Categories by Priority

Priority Category Impact Prefix
1 Async Patterns CRITICAL async-
2 Test Setup & Isolation CRITICAL setup-
3 Mocking Patterns HIGH mock-
4 Performance HIGH perf-
5 Snapshot Testing MEDIUM snap-
6 Environment MEDIUM env-
7 Assertions LOW-MEDIUM assert-
8 Test Organization LOW org-

Quick Reference

1. Async Patterns (CRITICAL)

  • async-await-assertions - Await async assertions (Vitest 5 fails unawaited ones)
  • async-return-promises - Return promises from test functions
  • async-fake-timers - Use fake timers for time-dependent code
  • async-waitfor-polling - Use vi.waitFor for async conditions
  • async-concurrent-expect - Use test context expect in concurrent tests
  • async-act-wrapper - Await user events to avoid act warnings
  • async-error-handling - Test async error handling properly

2. Test Setup & Isolation (CRITICAL)

  • setup-beforeeach-cleanup - Clean up state in afterEach hooks
  • setup-restore-mocks - Restore mocks after each test
  • setup-avoid-shared-state - Avoid shared mutable state between tests
  • setup-beforeall-expensive - Use beforeAll for expensive one-time setup
  • setup-reset-modules - Reset modules when testing module state
  • setup-test-factories - Use test factories for complex test data
  • setup-vitest5-migration - Plan the Vitest 5 migration deliberately (5.0)

Read the full file on GitHub · 123 lines

Files

What ships with it

46 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 22d ago Changed · +1 lines · -34 tokens per session 0ddeeb701b17
  2. 29d ago Changed · +1 lines 0e0ac995e585
  3. 1mo ago First seen · 121 lines · 46 tokens per session scan A 353024b8238f

Subscribe to this mod's changes

vitest is a skill published in the GitHub repository PyModel/react-frontend-skills (38 stars, last pushed 2d ago), licensed MIT. It adds 12 tokens to every session and 1,279 once invoked, about $0.0000 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

jest-unit

Unit testing skill using Jest for TypeScript and JavaScript, covering mocking, spies, snapshots, coverage, async testing, and custom matchers.

PramodDutta/qaskills · 32 tokens

library-testing

Use when creating or reviewing tests for a TypeScript library, including runtime tests, type tests, regression coverage, and CLI validation.

sampleXbro/agentsmesh · 29 tokens

typescript-quality-gates

Use when validating build quality, tsconfig rules, declaration output, linting, package integrity, or CI gates for a TypeScript library.

sampleXbro/agentsmesh · 33 tokens

quality-gates-typescript

Use when the repository holds a TypeScript project tested with Vitest — a React front end or a Node package with vitest in its package.json — and the software-engineer must produce falsifiable evidence for the quality gates, or run the StrykerJS mutation gates after a green baseline. Provides the cross-platform…

SebastienDegodez/skraft-plugin · 136 tokens

migrate-to-shoehorn

Migrate test files from as type assertions to @total-typescript/shoehorn. Use when user mentions shoehorn, wants to replace as in tests, or needs partial test data.

mxyhi/ok-skills · 48 tokens

mocking-inprocess-typescript

Use when the mocking-strategy-roster resolved (inprocess, TypeScript) — the override mocking strategy that replaces a downstream HTTP API with an in-process double (MSW answering at the network layer, or a hand-written gateway handed to the feature) in a Vitest integration test, instead of a Microcks container. Emits…

SebastienDegodez/skraft-plugin · 90 tokens