author-vitest-tests

Writes and reviews Vitest tests for Positron src/vs/ source code and React components.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing unit tests for Positron's src/vs/ codebase requires choosing the right test pattern (plain, DI builder, or React Testing Library), picking the correct test container preset, and following strict project conventions. This Skill automates that workflow, from analyzing a branch or PR for coverage gaps to writing, type-checking, and independently reviewing the tests.

Core Features & Use Cases

  • Branch/PR Test Gap Analysis: Analyzes a branch, PR number, or PR URL via a subagent to produce a structured test plan identifying which files need new or extended tests.
  • Pattern-Guided Test Authoring: Selects the correct Vitest pattern (plain, builder with createTestContainer, RTL prop-driven, or RTL service-context) based on the source file's dependencies, then writes tests following project conventions.
  • Verification and Independent Review: Runs targeted tests, strict TypeScript checks, ESLint for RTL files, and spawns a review subagent before a single full-suite run.
  • Use Case: A developer merges a feature branch touching several src/vs/ services and asks what tests are missing; the Skill analyzes the diff, proposes a test plan, writes the tests after confirmation, and has them independently reviewed.

Quick Start

Ask the assistant to analyze PR 12242 and write the missing Vitest tests for the changed Positron source files.

Frequently Asked Questions about author-vitest-tests

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

FAQPage Schema
How do I write Vitest tests for Positron source code?

Provide a file path, branch name, or PR number and the Skill analyzes the changes, picks the correct test pattern from the CLAUDE.md decision table, drafts a test plan for your confirmation, then writes and runs the tests with npx vitest.

How do I test React components with React Testing Library in Positron?

Components using only props use the RTL prop-driven pattern with setupRTLRenderer, while components calling usePositronReactServicesContext use withReactServices plus setupRTLRenderer. The Skill detects which pattern applies by inspecting the source file.

What is the difference between plain, builder, and RTL Vitest test patterns?

Plain tests cover pure functions with no services, builder tests use createTestContainer presets for classes needing dependency injection, and RTL tests render React components. The CLAUDE.md decision table determines which pattern fits each source file.

Can this Skill analyze a pull request for missing test coverage?

Yes, passing a PR number or URL triggers a Phase 1 analysis subagent that fetches the diff with gh pr diff, verifies changed symbols still exist, classifies each file, and returns a structured plan of tests to write or extend.

When should I not use Vitest for Positron tests?

If the CLAUDE.md decision table points to Core Mocha, Extension Host Mocha, or E2E Playwright for your source, Vitest is the wrong category and the Skill will tell you which test type fits instead of writing tests.

Why does my Vitest test pass but still show TypeScript errors?

npx vitest run does not catch strict TypeScript issues like overload incompatibility or missing stub properties. Run npm run test:positron:check-ts and grep for your test file to surface the same errors shown in the VS Code Problems pane.