write-tests

Guide colocated test file creation for TypeScript projects using Vitest.

78|5|Updated Jan 6, 2026
One-click install
npx skills add https://github.com/getsentry/abacus --skill write-tests-getsentry
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-tests
Source: https://github.com/getsentry/abacus/tree/main/.claude/skills/write-tests
Command: npx skills add https://github.com/getsentry/abacus --skill write-tests-getsentry

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps teams maintain high-quality code by guiding the creation and maintenance of tests that follow project conventions, ensuring tests are colocated with source files for faster discovery and execution.

Core Features & Use Cases

  • Colocated testing: Place tests next to the code they cover, reducing context switching.
  • Vitest-based: Uses Vitest for fast, running tests with familiar syntax.
  • Auth, mocks, and DB testing: Provides patterns for authenticated routes, MSW mocks, and in-memory PostgreSQL setups.
  • CI-friendly: Encourages test-driven practices that improve reliability and faster feedback.

Quick Start

Run tests with pnpm test to verify all colocated tests run. To add a new test, place it next to the related source file (for example, place a test alongside utils.ts as utils.test.ts) and rerun pnpm test to confirm it passes.

Frequently Asked Questions about write-tests

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

FAQPage Schema
How do I colocate tests with source files in a TypeScript project?

To colocate tests in a TypeScript project, place test files directly next to the source files they cover, such as utils.test.ts alongside utils.ts, to reduce context switching and improve file discovery.

What is the best way to set up MSW mocks for Vitest testing?

The best way to set up MSW mocks for Vitest testing is to follow colocated test patterns that provide structured mock setups for authenticated routes, ensuring reliable and fast validation of network requests.

How do I test authenticated routes using Vitest and colocated test patterns?

You can test authenticated routes using Vitest by applying convention-aligned colocated test patterns that provide specific scaffolding for auth testing, ensuring reliable validation of protected endpoints.

Can I use an in-memory PostgreSQL database for Vitest test scaffolding?

Yes, you can use an in-memory PostgreSQL database for Vitest test scaffolding. This approach provides isolated and fast database setups to ensure reliable test results without persistent data.

Does colocated testing improve CI reliability for TypeScript projects?

Colocated testing improves CI reliability for TypeScript projects by encouraging test-driven practices and maintaining convention-aligned test files, which yields faster feedback and more consistent execution.

Why should I colocate test files instead of using a separate tests directory?

You should colocate test files to reduce context switching between source and test files, maintain project conventions, and achieve faster test discovery and execution compared to fragmented test directories.