agentleFS
CaduS0uzaCaduS0uza/qa-supreme/skills/test-data-management/SKILL.md

test-data-management

Skill1 starsChanged 2 months agoMITView on GitHub

Design test data that makes tests fast, isolated and deterministic — factories over fixtures, per-test tenancy, frozen clocks, seeded randomness, and cleanup strategy. Use when tests interfere with each other, depend on a shared seed database, or fail only in CI.

  • Reads credentials

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    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:

    Read the test and you see exactly which fields drive the assertion.

    line 21
  2. Distinctive:

    Ordering: never assume database return order.

    line 40
  3. Very specific:

    Never copy production data into a test environment without anonymization — it is a breach waiting for a screenshot.

    line 44
  4. Distinctive:

    Prefer strategies that cannot leak: rollback, ephemeral namespace, containerized database per run.

    line 50

≈ “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 Data Management

Most flake and most false positives trace back to data: shared rows, leftover state, a clock that moved, an ID that collided.

Factories, not fixtures

A fixture file is a snapshot of assumptions that rot. A factory is a function with defaults and overrides — the test states only what it cares about:

const user = userFactory({ plan: 'pro' })              // everything else is a sane default
const order = orderFactory({ user, items: [item({ cents: 1000 })] })

Read the test and you see exactly which fields drive the assertion. That is the point.

Isolation ladder (pick the highest rung you can afford)

  1. In-memory / pure — no shared state at all.
  2. Transaction per test, rolled back after. Fast, total isolation, no cleanup code.
  3. Namespace per test — unique tenant/org/prefix per test, parallel-safe.
  4. Truncate between tests — slow, order-sensitive, last resort.
  5. Shared seeded database — where flake is born. Migrate away.

Parallel workers each need their own namespace or their own schema. A worker id in the tenant name (tenant-w${process.env.TEST_WORKER_INDEX}) is usually enough.

Determinism

  • Clock: inject it. vi.setSystemTime, freezegun, or a Clock port. Never new Date() inside code under test without a seam. Test the month-end and DST cases explicitly.
  • Randomness: seed it, and assert on the seeded output.
  • IDs: deterministic in tests (uuid('order', 1)), so failures are readable and diffs stable.
  • Ordering: never assume database return order. Assert on sets, or order explicitly.

Sensitive data

Never copy production data into a test environment without anonymization — it is a breach waiting for a screenshot. Generate realistic-looking data instead (@faker-js/faker, factory_boy, gofakeit), seeded so it is reproducible.

Cleanup

Prefer strategies that cannot leak: rollback, ephemeral namespace, containerized database per run. If you must delete, do it in a fixture teardown that runs even when the test fails, and verify the teardown ran — a silent teardown failure looks exactly like a flaky test tomorrow.

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.