agentleFS
joelhooksjoelhooks/uncomplect/skills/test-behaviour/SKILL.md

test-behaviour

Skill2 starsChanged 36 days agoMITView on GitHub

Pick the test shape that proves a behaviour. Use when you ask "how do I test this?", add a test, test a domain rule, a lifecycle, a retry, a session, a UI interaction, a timer, or a race, or review a test that might be tautological.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 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.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do not use fake timers, a clock, or a DOM.

    line 52
  2. Distinctive:

    Read UI behaviour is a scene for the Foldkit UI Toast race.

    line 64
  3. Distinctive:

    Run the test. It must fail.

    line 77
  4. Distinctive:

    Do not rewrite an expected result to match broken code.

    line 86

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

A test proves one behaviour. Name that behaviour before you write the test. Then pick the shape below that fits it.

Each shape returns a fixed, independent answer. A test that reruns the code under test cannot catch its mistakes. Read tests that earn their place first.

1. A domain rule: a property

A rule that holds for many inputs is an it.prop over Effect Arbitrary inputs. Use it.effect.prop when the check returns an Effect.

The events suite generates a sensitive key and requires its removal. The assertion does not call the filter to decide the answer:

Read property-based testing.

2. Anything with history: a model

Sessions, retries, and lifecycles depend on earlier steps. Generate command sequences and check the real system against a small model after each step.

The inspection lifecycle replays generated histories against the real actor:

Copy skills/add-a-lifecycle-machine/templates/lifecycle.model.test.md for a new machine. Read model-based testing.

3. UI behaviour: a Foldkit Scene

A Scene runs update, the view, and subscriptions together. Input and time are data:

  • Input is a step: pointerDown, click, type, or Subscription.emit.
  • Time is a Command. Resolve it with Command.resolve(WaitX, CompletedWaitX(...)).
  • Do not use fake timers, a clock, or a DOM.

A race is a plain assertion. Resolve a stale timer after the state has moved on, then assert that nothing broke.

Assert on what the view shows: roles, text, and data attributes. Do not assert on Model fields.

The reader's copy button resolves the copy and then its reset wait:

Read UI behaviour is a scene for the Foldkit UI Toast race.

4. A seam: one example

An example test fits one interface between parts, such as a service over the real filesystem. Keep one, and supply services through a Layer:

5. Always: plant a bug

  1. Break the behaviour the test protects.
  2. Run the test. It must fail.
  3. Restore the code. The test must pass.

Reject these tests:

  • A tautological test computes its expected answer with the code under test.
  • A change-detector test fails on any edit and proves no rule.
  • A regression test for a bug the suite already covers adds nothing.

Do not rewrite an expected result to match broken code.

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.