agentleFS
tarikhamiltontarikhamilton/claude-skills/skills/test-conventions/SKILL.md

test-conventions

Skill0 starsChanged 5 months agoMITView on GitHub

Testing conventions, selector best practices, DRY patterns, and coverage gap analysis. Use when writing, reviewing, or planning tests, or when the user asks what needs testing.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 4 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Avoid unnecessary snapshots unless the repo already relies on them.

    line 11
  2. Very specific:

    Test file location: *.test.*, *.spec.*, or __tests__/ directories.

    line 12
  3. Very specific:

    Check package.json devDependencies for jest, vitest, @testing-library/*, detox, etc.

    line 16
  4. Distinctive:

    Look at existing test files for import patterns and conventions already in use.

    line 17
  5. Distinctive:

    Use test factories/builders for common test data instead of duplicating object literals.

    line 36
  6. Distinctive:

    When asked "what needs testing?" or to find test gaps:

    line 43

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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

Test Conventions

Deterministic Tests

  • Mock network calls, timers, and randomness — tests must not depend on external state.
  • Avoid unnecessary snapshots unless the repo already relies on them.
  • Test file location: *.test.*, *.spec.*, or __tests__/ directories.

Stack Detection

Identify the test stack before writing anything:

  • Check package.json devDependencies for jest, vitest, @testing-library/*, detox, etc.
  • Look at existing test files for import patterns and conventions already in use.
  • Match the existing stack — don't introduce a new test runner or library.

Selector Best Practices

Hierarchy of preference (most to least stable):

  1. testID props — always prefer these for element selection
  2. Accessibility role / label — stable and meaningful
  3. Semantic query (e.g., getByRole, getByLabelText)
  4. Last resort: structure-based selectors

Never do:

  • Query by display text or copy — breaks when copy changes
  • Query by element count or string count — strings repeat across components
  • Tie selectors to internal component structure, nesting depth, or class names

DRY Testing

  • Extract shared setup into beforeEach or helper functions.
  • Use test factories/builders for common test data instead of duplicating object literals.
  • Share common assertions via custom matchers or helper functions.
  • Parameterize similar tests with test.each / it.each instead of copy-pasting test cases.
  • Extract common render + setup patterns into helper functions (e.g., renderWithProviders).

Coverage Gap Analysis

When asked "what needs testing?" or to find test gaps:

  1. Scan for untested modules — find source files with no corresponding test file.
  2. Prioritize by risk:
    • Critical user paths (auth, payments, core flows) > recently changed code > complex branching logic
  3. Flag zero-coverage modules — components or utilities with no test file at all.
  4. Check edge cases — look for error handling, boundary conditions, and fallback logic that existing tests skip.

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.