Vitest Mock Isolation Review

Vitest Mock Isolation Review is a skill for Claude Code from s977043/river-review. It costs 48 tokens per session (1,141 once invoked), scanned A, original, MIT.

A Vitest review check for test isolation, mock cleanup, asynchronous assertions, and shared mutable state. Vitest is a JavaScript and TypeScript test runner; test isolation means one test does not affect another.

In plain words
What is it for?
It is for reviewing changes that use Vitest mocks, spies, or asynchronous expectations and identifying missing cleanup or missing await or return statements.
Why use it?
It helps find tests that pass or fail depending on execution order, or that appear to pass without actually waiting for an assertion.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the river-review plugin — 138 skills, 18 commands, 5 agents, 3 hooks shipped together

Good fit It is for reviewing changes that use Vitest mocks, spies, or asynchronous expectations and identifying missing cleanup or missing await or return statements.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/s977043/river-review/vitest-mock-isolation
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 s977043/river-review --skill vitest-mock-isolation
Clone the repo
git clone --depth 1 https://github.com/s977043/river-review

Made for: Claude Code.

Or install river-review, the plugin that ships this one along with the rest of its 138 skills, 18 commands, 5 agents, 3 hooks.

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 Mock Isolation Review

README.md
[![agentmods](https://agentmods.dev/badge/skills/s977043/river-review/vitest-mock-isolation/github.svg)](https://agentmods.dev/skills/s977043/river-review/vitest-mock-isolation)
Your own site
<a href="https://agentmods.dev/skills/s977043/river-review/vitest-mock-isolation"><img src="https://agentmods.dev/badge/skills/s977043/river-review/vitest-mock-isolation/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 Mock Isolation Review

Your own site · 80×15
<a href="https://agentmods.dev/skills/s977043/river-review/vitest-mock-isolation"><img src="https://agentmods.dev/badge/skills/s977043/river-review/vitest-mock-isolation.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 48 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,141 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.00048 $0.01141
Opus 5 $0.00024 $0.00571
Sonnet 5 $0.00010 $0.00228
Haiku 4.5 $0.00005 $0.00114

Measured 7d ago against content hash 69808f75f5de, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

Vitest Mock Isolation Review 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 7d 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/midstream/vitest-mock-isolation/SKILL.md · 76 lines

How it starts

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

Pattern declaration

Primary pattern: Reviewer Secondary patterns: Inversion Why: Vitest 固有の mock lifecycle と async expect 契約をチェックリスト型で検査し、設定不明時はゲートで止める。

Goal / 目的

  • vi.spyOn / vi.mock の未復元によりテスト間でモック状態が漏れ、実行順序依存の flaky を生むのを防ぐ。
  • expect(...).resolves / .rejects の await/return 漏れによる「常に pass する空 assertion」を検出する。
  • モジュールスコープの可変状態がテスト間でリークするのを検出する。

Non-goals / 扱わないこと

  • テストの存在有無・カバレッジ・命名は downstream test スキルの領域であり、本スキルでは扱わない。
  • どのアサーションライブラリを使うべきかの選定。
  • テスト対象の実装ロジックの正しさ(本スキルは mock lifecycle と async expect 契約に限定)。

Pre-execution Gate / 実行前ゲート

このスキルは以下の条件がすべて満たされない限りNO_REVIEWを返す。

  • 差分に vi.mock / vi.spyOn / expect(...) の追加・変更が含まれている
  • diff コンテキストが利用可能である

ゲート不成立時の出力: NO_REVIEW: vitest-mock-isolation — mock / spy / expect の変更なし

False-positive guards / 抑制条件

  • vitest config(vitest.config.ts / vite.config.ts)で test.restoreMocks: true / clearMocks: true / mockReset: true が設定されている場合、afterEach の明示呼び出しが無くても指摘しない。diff だけで設定が見えない場合は断定せず質問に留める。
  • vi.fn() をローカル変数で都度生成し再利用していないケースはリーク源でないため指摘しない。
  • setupFiles で指定された setup ファイルが意図的にグローバルモックを共有する場合は、別スコープとして扱い指摘しない。

抑制時の出力: 該当する指摘を出力しない(黙る)。

Rule / ルール

  • vi.spyOn / vi.mock を使う場合、afterEach(() => vi.restoreAllMocks())(spy 復元)または vi.clearAllMocks() の呼び出し、もしくは config の restoreMocks: true 等のいずれかを満たすことを確認する。いずれも無ければモック状態がテスト間で漏れる。
  • expect(promise).resolves / .rejectsawait または return する。async テスト内で await されない expect は検出する。
  • モジュールスコープの可変変数を複数テストが書き換える場合、beforeEach 等でのリセットを確認する。

Evidence / 根拠の取り方

  • 指摘は <file>:<line> で差分に紐づけ、Vitest 公式の該当規約(mock restore / async assertion)を 1 行で添える。
  • config が diff 外にあり確認できない場合は断定せず「可能性」として質問に留める。

Output / 出力(短文版の推奨)

コメントは日本語で返す。

  • Finding: どの分離契約に反しているか(1文)
  • Impact: テスト間状態リーク / 実行順序依存 flaky / 常に pass する空 assertion 等
  • Fix: afterEach(vi.restoreAllMocks) / restoreMocks: true / await expect(...).rejects の最小修正案

Sources / 出典

Read the full file on GitHub · 76 lines

Files

What ships with it

3 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. 7d ago First seen · 76 lines · 48 tokens per session scan A 69808f75f5de

Subscribe to this mod's changes

Vitest Mock Isolation Review is a skill published in the GitHub repository s977043/river-review (3 stars, last pushed today), licensed MIT. It adds 48 tokens to every session and 1,141 once invoked, about $0.0002 per session on Opus 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-09-03.

Related

Other skills, from other repositories

testing-react

Writes React/TypeScript tests using Vitest and React Testing Library. Use when "write react tests", "vitest", "component test", "hook test", "RTL", "testing library", "snapshot test", or testing React components, hooks, and utilities.

iliaal/whetstone · 57 tokens

brooks-test

Test quality review drawing on twelve classic engineering books — with primary focus on xUnit Test Patterns, The Art of Unit Testing, How Google Tests Software, and Working Effectively with Legacy Code — that diagnoses structural problems in an existing test suite: brittleness, mock abuse, coverage illusions, slow…

hyhmrright/brooks-lint · 161 tokens

test-implement

Implements React/TypeScript unit, integration, and browser E2E tests with the repository's configured runner, mocks, setup, and browser harness. Use when creating or completing frontend tests and generated test skeletons.

shinpr/claude-code-workflows · 48 tokens

coverage

Compute code coverage for active track or module. Targets 95%+ coverage with report and justification for uncovered lines. Complements TDD workflow.

drafthq/draft · 31 tokens

testing-laravel

Writes Laravel tests using PHPUnit. Use when "write tests", "add tests", "phpunit", "laravel test", "feature test", "unit test", "mock", "factory", or testing controllers, models, services, actions, jobs, artisan commands, or API endpoints.

iliaal/whetstone · 63 tokens

review-all

Multi-agent code review for diffs (project-agnostic). Covers standards, bugs, security, DRY, smells, perf, tests, API contracts, a11y/i18n. Verifies each finding to eliminate false positives. Use for /review-all, pre-PR/pre-commit review, or auditing uncommitted/staged changes.

ncoevoet/claude-review-all · 74 tokens