Skip to content
OpenAgentSkill
Browsing is open · Catalog captured 2026-11-21 · Automatic updates and account services are paused.
Development

test-writer

Write, extend, or review tests in any codebase. Use this skill whenever the user asks to write tests, add test coverage, test a new feature, fix failing tests, or audit existing test files — regardless of language, framework, or project. Also trigger for "add tests for", "write tests for", "cover this with tests", "test this file", "update the tests", "improve coverage", or "this needs tests". This skill enforces universal testing rules (no .skip, no lowering thresholds, full-path coverage) and adapts its mock patterns and tooling to whatever stack the repo uses.

anchildress1 · Static checks on file

Installation

Read the source and dependencies before running a command. Copying does not install or execute anything.

npx skills add anchildress1/awesome-github-copilot --skill test-writer

About this skill


status: ready name: test-writer description: > Write, extend, or review tests in any codebase. Use this skill whenever the user asks to write tests, add test coverage, test a new feature, fix failing tests, or audit existing test files — regardless of language, framework, or project. Also trigger for "add tests for", "write tests for", "cover this with tests", "test this file", "update the tests", "improve coverage", or "this needs tests". This skill enforces universal testing rules (no .skip, no lowering thresholds, full-path coverage) and adapts its mock patterns and tooling to whatever stack the repo uses.

Test Writer

You are writing production-quality tests. These rules apply to every repo, every language, every test framework.

Step 0: Orient Before You Write

Do ALL of the following before writing a single line of test code — in parallel where possible:

  1. Read the source file(s) under test completely. Map every branch, early return, validation check, and error path.
  2. Detect the stack and test framework — see Stack Detection below.
  3. Find the test run command. Check package.json scripts.test, Makefile, pyproject.toml, or the repo's CI config. You will need this for verification.
  4. Read the existing test files for the module (if any). Extract mock patterns, fixture shapes, and naming conventions — your new tests must be consistent with them.
    • If no test files exist, establish conventions: check for a tests/ or __tests__/ directory; if none, create one mirroring the source structure.
  5. Read the test config (vitest.config.ts, jest.config.ts, pytest.ini, pyproject.toml). Note coverage thresholds and excluded paths.
  6. Read test helpers and shared fixtures. Use what exists before inventing new utilities.
  7. Identify which test types apply: unit, integration, end-to-end, performance, Lighthouse CI (LHCI). Each has different mock boundaries and scope.
  8. Read CLAUDE.md or AGENTS.md for project-specific test conventions.

Stack Detection and File Placement

Detect the framework from config files before writing anything:

SignalFramework
vitest.config.ts or vitest in package.jsonVitest
jest.config.* or jest in package.jsonJest
pytest.ini, pyproject.toml [tool.pytest]pytest
.mocharc.*Mocha
cypress.config.*Cypress (e2e)
playwright.config.*Playwright (e2e)

File placement — match the repo's existing convention:

  • If test files live next to source (src/foo.ts → src/foo.test.ts), follow that.
  • If test files live in a separate tree (tests/foo_test.py), follow that.
  • When bootstrapping: prefer co-location for unit tests; prefer tests/ for integration and e2e.

Naming — match what already exists:

  • TypeScript/JavaScript: <module>.test.ts or <module>.spec.ts
  • Python: test_<module>.py (standard pytest convention)
  • Do not mix naming styles within a project.

The Rules

These apply in every repo. They exist because deviations silently erode test suite confidence.

No .skip. Skipped tests are lies the suite tells future readers. If a test fails, diagnose the real cause — in source, in the mock, or in the test logic — and fix it.

No lowering coverage thresholds. If coverage drops, the answer is more tests. The threshold in the config is a floor.

No copy-paste test bodies. Shared setup belongs in beforeEach (or equivalent). Tests that differ only in input/output belong in parametric form (it.each, @pytest.mark.parametrize).

Assert both result shape and mock interactions. Checking only the return value misses downstream call correctness. Checking only mock calls misses what the caller actually produces. Do both.

Tests must be self-contained. No test should depend on execution order or mutable state that beforeEach does not reset. A test that passes in isolation but fails in a suite is a broken test.

Fix the source, not the assertion. If you discover a bug while writing tests, fix it in the source code first, then write the test against correct behavior. Adjusting the assertion to match wrong behavior documents a bug instead of catching it.


Test Naming

Name tests so a reader who has never seen the source understands what is verified and under what condition — without reading the body.

it('returns 404 when the card does not exist')
it('normalizes whitespace-only url to undefined')
it('rejects signal above 5')
it('excludes soft-deleted cards from results by default')
it('includes soft-deleted cards when include_deleted is true')
it('handles partial batch failure without failing the whole run')

Pattern: verb + subject + condition. Avoid it('works'), it('test 1'), it('should be correct').

Group related tests under describe blocks that encode shared context:

describe('when input is valid')
describe('when the database returns an error')
describe('when deleted_at is provided')

Test Structure: Arrange → Act → Assert

Every test follows this shape. Make sections visually obvious with blank lines in longer tests:

it('creates a card and returns the persisted record', async () => {
  // Arrange
  const input = buildValidCard({ title: 'My Note' });
  mockDb.upsert.mockResolvedValue({ data: input, error: null });

  // Act
  const result = await handleWriteCards(supabase, [input]);
  const body = asTextJson(result);

  // Assert
  expect(body.written).toBe(1);
  expect(body.results[0].title).toBe('My Note');
  expect(mockDb.upsert).toHaveBeenCalledWith(
    expect.objectContaining({ title: 'My Note' }),
    expect.anything(),
  );
});

Required Coverage: Every Path

For every function, method, handler, or route you test, work through this in order. "Obvious" paths are where regressions hide — do not skip a row.

PathWhat to test
Happy pathValid input, all require
Read the complete source ↗