review-vitest-tests

Reviews Vitest test files against Positron's builder patterns and RTL conventions.

4.2k|179|Updated May 24, 2022
One-click install
npx skills add https://github.com/posit-dev/positron --skill review-vitest-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: review-vitest-tests
Source: https://github.com/posit-dev/positron/tree/main/.claude/skills/review-vitest-tests
Command: npx skills add https://github.com/posit-dev/positron --skill review-vitest-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Reviewing Vitest unit tests for correctness, maintainability, and adherence to project conventions is time-consuming and error-prone, especially when tests contain subtle issues like leaky spies, mis-scoped emitters, or tests that verify implementation details instead of behavior.

Core Features & Use Cases

  • Structured 12-point checklist review: Evaluates test value and falsifiability, anti-patterns, setup weight, mock minimality, edge-case coverage, isolation, emitter scoping, spy cleanup, and snapshot appropriateness.
  • Lint and suppression auditing: Runs ESLint with testing-library and jest-dom rules, greps for eslint-disable suppressions, wide as unknown as casts, and private-method test seams.
  • Cross-file consistency checks: Compares conventions against neighboring test files and flags inconsistent stubbing or assertion styles.
  • Use Case: After writing a new .vitest.tsx test suite for a Positron service, run this review to catch a new Emitter() created inside an it() block that would break event wiring through the test builder.

Quick Start

Review the Vitest test file at src/vs/workbench/services/example/test/myService.vitest.ts against the project checklist and report only failing items.

Frequently Asked Questions about review-vitest-tests

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

FAQPage Schema
How do I review Vitest unit tests for quality issues?

Run this review on the test file path; it reads the test and its source file, applies a 12-point checklist covering falsifiability, anti-patterns, isolation, and coverage, then reports only failing items with concrete fixes.

What anti-patterns does Vitest test review catch?

It catches wide `as unknown as` interface casts, private-method test seams, eslint-disable suppressions of testing-library or jest-dom rules, emitters scoped inside `it()` blocks, unrestored spies, and tests verifying implementation details rather than behavior.

Does this review work for Playwright or e2e tests?

No. The review is scoped strictly to Vitest unit test files (.vitest.ts and .vitest.tsx). End-to-end and Playwright tests follow different conventions and are explicitly out of scope.

Why do my Vitest tests leak state between runs?

Common causes are shared mutable state, missing spy restoration, or emitters created inside `it()` callbacks instead of at describe level. The review's isolation, emitter scoping, and spy cleanup checks identify exactly these leaks.

When should inline snapshots be avoided in Vitest tests?

Avoid inline snapshots when explicit assertions would be clearer, when output is large or contains unstable fields like timestamps or generated ids, or when only a few properties matter. Project to relevant fields or use direct toBe/toEqual assertions instead.