agentleFS
andeeplusandeeplus/aplus/skills/testing/SKILL.md

testing

Skill1 starsChanged 56 days agoMITView on GitHub

Write, review and place automated tests that can fail. Use for writing, generating or reviewing tests, choosing a layer (unit, DOM, runtime-specific, end-to-end, benchmark), or rejecting a test that cannot fail. Covers Vitest and Playwright.

  • Reads credentials

123 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use oss-pr, pr-automation and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • CES-LtdSkill

    oss-pr

    Use when creating a pull request, after committing changes, or when user invokes /oss-pr. Covers branch management, quality checks, commit, push, and PR creation.

    Also in 3 projects that use this

  • CES-LtdSkill

    pr-automation

    PR Automation Orchestrator: poll open PRs, check CI, run review, fix, and merge eligible PRs. Use when: (1) Invoked by daemon via scripts/pr-automation.sh, (2) User says "/pr-automation".

    Also in 3 projects that use this

  • ffsshhttiikkSkill

    cicd

    Continuous integration and delivery pipelines

    Also in 4 projects that use this

  • ffsshhttiikkSkill

    networking

    Practical application and coding skills for Networking

    Also in 3 projects that use this

  • JohnJBorenSkill

    ci-cd

    CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies

    Also in 9 projects that use this

  • Cogni-AI-OUSkill

    dotfiles

    Reference for repository dotfiles, including their purposes, standard configurations, and usage guidelines. You MUST load this skill when configuring, troubleshooting, or understanding repository dotfiles.

    Also in 3 projects that use this

  • +2 more from CES-Ltd
  • +1 more from ffsshhttiikk

The file

We split this skill into the rules it gives an agent

12 rules. 0 are common, 11 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 105 edited versions we read keep these.

  • 11

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Stop at the first layer that can fail for the bug you care about:

    line 23
  2. Distinctive:

    Check what runs the test. A file outside every include glob of the test config never runs, and green CI then proves nothing.

    line 31
  3. Distinctive:

    Test a decision or a boundary:

    line 35
  4. Distinctive:

    A bug's scenario is its test: When a bug has a Gherkin scenario, the regression test implements it: Given, When and Then become arrange, …

    line 58
  5. Distinctive:

    A test can pin a bug: When a test contradicts the documented contract, fix the test and say so in the PR.

    line 60
  6. Distinctive:

    Default: do not mock. Feed data in, read data out.

    line 91
  7. Distinctive:

    If a new test mocks every collaborator, delete the mocks and test the pure core instead.

    line 95
  8. Distinctive:

    Treat tests an agent wrote, your own included, as a draft:

    line 99
  9. Distinctive:

    Run them at once, one file in run mode, and fix import and API errors.

    line 101
  10. Distinctive:

    Look for the edge cases: empty input, a missing required field, a render that throws, every runtime the code supports.

    line 103
  11. Distinctive:

    When you delegate tests to a subagent, list the cases to cover, not "write tests for this file".

    line 105
  12. Very specific:

    Always use run mode (vitest run, playwright test).

    line 109

“Common” is measured: kept by at least 6 in 10 of the 105 edited versions of this file we could read. “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

A test exists to catch a behaviour change someone would care about. A test that cannot fail unless the test file itself changes is waste. Prefer a few tests that pin a contract over a suite that restates the implementation.

Project specifics (test layers, commands, where files go, shared fixtures) come from the project's AGENTS.md and the project skill it names, then from the test config. Match the nearest existing test in the same package, and use the project's domain terms.

References

TaskRead
Writing any test: placement, naming, files on disk, stub hygienereferences/conventions.md
A cache, incremental build or invalidation pathreferences/cache-and-invalidation.md
A test that needs a real DOMreferences/browser.md
A Playwright spec or fixturereferences/e2e.md

Choose a layer

Stop at the first layer that can fail for the bug you care about:

  1. Unit: pure decisions and mappings, in process, no DOM.
  2. DOM: code that owns the DOM, such as navigation, hydration or custom elements.
  3. Runtime-specific: what only one runtime provides. Test the logic under the default runtime with the runtime injected or stubbed; use the real one only when the assertion needs it.
  4. End-to-end: the wired system, such as a dev server, real navigation, HTTP headers or build output.
  5. Benchmark: cost, not correctness. Back a performance claim with a before-and-after run of the project's benchmark. Never assert wall-clock time in a test.

Check what runs the test. A file outside every include glob of the test config never runs, and green CI then proves nothing.

What to test

Test a decision or a boundary:

  • Input that must be rejected or left out: a missing required config field, a page whose metadata throws, a request no route matches
  • Input that used to take the wrong branch: the most specific of several matching routes wins
  • A mapping that would silently drift: a cache strategy to its cache-control header, a file extension to its handler
  • Order independence: a result must not depend on glob order or on which test ran first
  • Failure the user would see: an error page instead of a 404, a page missing from the output, stale HTML after an edit

Do not test:

  • That a constant equals itself
  • That something you just built is toBeDefined() or toBeTruthy()
  • That a mock was called, unless the call is the contract (then assert its arguments)
  • A restatement of the implementation, or your own test double
  • Private members reached with a cast. If a behaviour is not observable through the public surface, the seam is wrong
  • Snapshot dumps of whole objects "to have something"

Litmus: if someone rewrote the internals and the user-visible result stayed the same, would this test fail? If yes, it is coupled to the implementation. Rewrite it against the result.

One non-trivial branch, loop, parser or trust boundary needs one test that fails if that logic breaks. Do not add a describe per function for coverage.

Test-only API is dead API. Do not add an exported setter, a getter, a counter or a flag that exposes internal state so a test can reach in. If only a test calls a symbol, delete both. A parameter that replaces a process boundary (a clock, a runtime, a filesystem) is a seam, not test-only API.

A bug's scenario is its test. When a bug has a Gherkin scenario, the regression test implements it: Given, When and Then become arrange, act and assert, and the test takes the scenario's title.

A test can pin a bug. When a test contradicts the documented contract, fix the test and say so in the PR. Never bend correct code to keep a test green.

Tautology (reject these)

// a constant equals itself
expect(Priority.HIGH).toBe(100);

// asserts nothing
expect(watcher).toBeDefined();

// reimplements the unit: the test sorts, the code under test never runs
const sorted = [...handlers].sort((a, b) => b.priority - a.priority);
expect(sorted[0].name).toBe('integration');

// mock theatre
expect(fileSystem.write).toHaveBeenCalled();

Rewrite until the assertion names a value, error or visible state the production code could get wrong:

expect(sitemapUrls).toEqual(['https://example.com/', 'https://example.com/about']);
expect(response.headers.get('cache-control')).toBe('no-store, must-revalidate');
expect(readFileSync(path.join(outDir, 'index.html'), 'utf8')).toContain('<h1>Home</h1>');

For priority logic, give the code two handlers that both match one input and assert which one handled it.

Mocks

Default: do not mock. Feed data in, read data out.

Mock at a process boundary: the network, the clock, a runtime global, a child process, the environment. The filesystem is usually not one; use a temp dir. Spy on it only to force what a real disk will not give on demand, such as an ordering or a failed write. Assert what crossed the boundary (URL, method, body, the path and content written), not how often an internal helper ran.

If a new test mocks every collaborator, delete the mocks and test the pure core instead.

Generated tests

Treat tests an agent wrote, your own included, as a draft:

  1. Run them at once, one file in run mode, and fix import and API errors.
  2. Throw out tautologies, mock-only assertions, APIs from another framework (jest.* in a Vitest project), casts into private members, and direct process.env writes.
  3. Look for the edge cases: empty input, a missing required field, a render that throws, every runtime the code supports. Add them, or delete a happy-path-only file.

When you delegate tests to a subagent, list the cases to cover, not "write tests for this file".

Running

Always use run mode (vitest run, playwright test). Watch mode never exits and hangs the agent.

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.