test-writer

Write integration and unit tests for this codebase. Generate test files following repo patterns. Use when adding tests, improving coverage, writing test cases, or creating test suites.

⭐8stars🔀0forks📁View on GitHub🕐Updated Jan 3, 2026

When & Why to Use This Skill

The Test Writer skill automates the creation of high-quality unit and integration tests by analyzing and mimicking existing repository patterns. It streamlines the software development lifecycle by generating framework-specific test files (such as Vitest and Jest) for API endpoints, mobile components, and shared packages, ensuring consistent code coverage and adherence to security best practices.

Use Cases

  • Automating the generation of integration tests for new API endpoints to validate authentication, input validation, and successful CRUD operations.
  • Creating Jest-based unit tests for React Native components within mobile applications to ensure UI logic and component stability.
  • Improving overall repository code coverage by identifying untested shared packages and generating test suites that follow local architectural patterns.
  • Validating security guardrails by automatically writing test cases for edge cases, such as 401 Unauthorized and 403 Forbidden response codes.
  • Streamlining the testing workflow by executing pnpm commands to run specific test files, manage local dev servers, and verify deterministic results.
nametest-writer
descriptionWrite integration and unit tests for this codebase. Generate test files following repo patterns. Use when adding tests, improving coverage, writing test cases, or creating test suites.
allowed-toolsRead, Grep, Glob, Write, Edit, Bash

Test Writer

Creates tests following this repo's testing patterns.

When to Use

  • "Write tests for..."
  • "Add test coverage for..."
  • "Create integration test"
  • "Test this endpoint"
  • "Add unit tests for mobile"

Test Locations

Type Location Framework
Integration tests packages/tests/src/ Vitest
Mobile unit tests apps/mobile/__tests__/ Jest
Tools testing packages/tools-testing/ Custom
Evals packages/evals/ Custom

Procedure

Step 1: Identify What to Test

Determine test type needed:

  • API endpoint → Integration test in packages/tests/src/
  • React Native component → Unit test in apps/mobile/__tests__/
  • Shared package → Integration or unit test in package

Step 2: Read Existing Tests

Study patterns in existing tests:

Read: packages/tests/src/auth.cookie.test.ts
Read: packages/tests/src/stream.test.ts

Step 3: Write Test File

Use templates from templates.md.

Key patterns:

  • Use describe for grouping
  • Use it for test cases
  • Import helpers from ./http.ts
  • Use getTestToken() for auth

Step 4: Run Tests

# Integration tests (requires web server)
pnpm -C apps/web dev &  # Start server
pnpm test:integration

# Mobile unit tests
pnpm -C apps/mobile test

# Single test file
pnpm -C packages/tests vitest run src/{file}.test.ts

Step 5: Check Coverage

Ensure tests cover:

  • Happy path (success case)
  • Authentication (401 for protected routes)
  • Validation (400 for bad input)
  • Authorization (403 for forbidden)
  • Edge cases

Test Categories

Must Test

  • API endpoints (auth, validation, success)
  • Database operations (CRUD)
  • Authentication flows
  • Rate limiting behavior
  • Error handling

Should Test

  • Input edge cases
  • Concurrent requests
  • Token expiration
  • Mobile-specific flows

Guardrails

  • ALWAYS follow existing test patterns
  • ALWAYS clean up test data after tests
  • NEVER hardcode credentials in tests
  • NEVER skip authentication tests
  • Use environment variables for config
  • Tests must be deterministic (no random failures)