agentleFS
justinwilliamesjustinwilliames/skills/testing-standards/SKILL.md

testing-standards

Skill1 starsChanged 5 months agoMITView on GitHub

Use this skill when the user invokes /testing-standards, asks about the project's testing approach, asks how to write tests, asks what tests to write for a feature, or needs a reminder of TDD workflow. Also trigger when the user says "write tests first", "what tests do I need", "set up testing", or "add tests for X". This skill defines the canonical testing philosophy, tooling, file conventions, and Claude's own rules for writing tests. Do NOT invoke for a project with no test runner configured — fill in the "Before first use" section below first.

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

18 rules. About 0 are common, 14 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈14

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    All new features must follow TDD.

    line 31
  2. Distinctive:

    Before writing any feature code, write tests covering all expected flows and edge cases

    line 34
  3. Distinctive:

    Run the tests — they should all fail (this confirms the tests are real and wired up correctly)

    line 35
  4. Distinctive:

    Never mark a feature done until all tests are green

    line 37
  5. Distinctive:

    Test individual functions, components, hooks, and API handlers in isolation

    line 46
  6. Distinctive:

    Test complete user flows through the real browser (no mocks for the critical path)

    line 52
  7. Distinctive:

    Run through the app in a headless browser and capture screenshots at every meaningful state

    line 65
  8. Distinctive:

    Write the test file first

    line 112
  9. Distinctive:

    Run tests, confirm they fail, then start implementing

    line 114
  10. Distinctive:

    Keep building until all tests pass before moving on

    line 115
  11. Very specific:

    Run npm run test:all before starting

    line 118
  12. Distinctive:

    Run again after every meaningful change

    line 119
  13. Distinctive:

    If any test fails that wasn't failing before: fix it immediately, don't continue building

    line 120
  14. Very specific:

    Add screenshot captures for all relevant states in e2e/visual.spec.ts

    line 123
  15. Very specific:

    Run npm run test:e2e and review the new screenshots before proceeding

    line 124
  16. Distinctive:

    If tests are failing and you can't immediately fix them, stop and explain why before continuing

    line 127
  17. Very specific:

    Keep realistic test fixtures in tests/fixtures/.

    line 134
  18. Distinctive:

    When you *intentionally* change the UI (new design, refactor), update baselines explicitly:

    line 140

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Testing Standards

Before first use

Fill in the following for the project before relying on this skill:

  • Test runner: [e.g. Vitest, Jest, Pytest — replace the placeholder in § Test Suites below]
  • Unit test command: [e.g. npm run test]
  • E2E test command: [e.g. npm run test:e2e]
  • Full suite command: [e.g. npm run test:all]
  • Key user flows to cover: [list the primary E2E journeys specific to this project]

Until these are filled in, this skill is a template, not a working standard.

Failure modes

SituationWhat to do
Broken suite on arrivalRun the full suite first. Fix or flag every pre-existing failure before writing new tests — never add tests on top of a red suite.
Missing runnerIf no test runner is configured for the project, stop. Tell the user to install and configure one, then fill in "Before first use" above. Do not invent or assume a runner.
CI-only testsIf tests are configured to run only in CI (no local runner), say so explicitly. Do not claim local verification has passed — it hasn't.

Philosophy: Test-Driven Development

All new features must follow TDD. No exceptions.

The workflow:

  1. Before writing any feature code, write tests covering all expected flows and edge cases
  2. Run the tests — they should all fail (this confirms the tests are real and wired up correctly)
  3. Build the feature incrementally until every test passes
  4. Never mark a feature done until all tests are green

This catches edge cases early, prevents regressions, and gives future changes a safety net.


Test Suites

1. Unit / Integration Tests

  • Test individual functions, components, hooks, and API handlers in isolation
  • Cover: happy path, edge cases, error states, boundary values
  • Tool: [Vitest / Jest — pick one and note it here]
  • Location: __tests__/ alongside source files, or *.test.ts co-located

2. End-to-End Tests

  • Test complete user flows through the real browser (no mocks for the critical path)
  • Cover: every major user journey from entry point to completion
  • Tool: Playwright
  • Location: e2e/

Flows to cover (update this list as the app grows):

  • User can sign up and land on dashboard
  • User can [core action #1]
  • User can [core action #2]
  • Error states show correctly (network failure, 404, validation)
  • Auth gates redirect unauthenticated users

3. UI Regression / Screenshot Tests

  • Run through the app in a headless browser and capture screenshots at every meaningful state
  • Compare against baseline images; flag any pixel diffs
  • Tool: Playwright (built-in screenshot + visual comparison)
  • Location: e2e/screenshots/ for baselines, e2e/screenshots/diff/ for failures

States to capture for every major screen:

  • Empty state (no data)
  • Loaded state (with realistic test data)
  • Error state
  • Loading/skeleton state (if applicable)
  • Mobile viewport (375px)
  • Dark mode (if supported)

To review all screenshots at once:

open e2e/screenshots/
# or
npx playwright show-report

This gives a quick visual skim of the entire app across all states — useful before any major merge.


Running Tests

# Unit tests
npm run test

# Unit tests in watch mode (during development)
npm run test:watch

# E2E + screenshots (headless)
npm run test:e2e

# Update screenshot baselines (after intentional UI changes)
npm run test:e2e -- --update-snapshots

# Full suite (run before every commit)
npm run test:all

Rules for Claude When Writing Code

  1. Writing a new feature?
    • Write the test file first
    • Include: happy path, at least two edge cases, one error state
    • Run tests, confirm they fail, then start implementing
    • Keep building until all tests pass before moving on
  2. Modifying existing code?
    • Run npm run test:all before starting
    • Run again after every meaningful change
    • If any test fails that wasn't failing before: fix it immediately, don't continue building
  3. Adding a new screen or major UI component?
    • Add screenshot captures for all relevant states in e2e/visual.spec.ts
    • Run npm run test:e2e and review the new screenshots before proceeding
  4. Never leave a test suite in a broken state.
    • If tests are failing and you can't immediately fix them, stop and explain why before continuing
    • A green test suite is a prerequisite for any new work

Test Data

Keep realistic test fixtures in tests/fixtures/. Use these consistently across unit, E2E, and screenshot tests so results are reproducible and comparable.


Screenshot Baseline Updates

When you intentionally change the UI (new design, refactor), update baselines explicitly:

npm run test:e2e -- --update-snapshots

Then commit the updated PNGs alongside the code change. Reviewers can visually diff the screenshots in the PR to confirm the change looks right.

Sync home

Sync home: canonical = your live private copy; public sanitized twin: ~/code/skills/testing-standards → github.com/justinwilliames/skills. Sanitization is a sync step.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.