agentleFS
idavidov13idavidov13/agentic-playwright/.agents/skills/fixtures/SKILL.md

fixtures

Skill268 starsChanged 11 days agoMITView on GitHub

Use when registering a page object as a fixture, adding a setup/teardown fixture, adding a new fixture category, or deciding whether reusable code is a fixture or a plain helper. Not for the page-object class itself (see `page-objects`) or plain functions (see `helpers`).

2 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

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    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. Very specific:

    Every fixture is typed in FrameworkFixtures or HelperFixtures.

    line 13
  2. Very specific:

    Run npx tsc --noEmit, then the spec that consumes the fixture.

    line 47

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

Fixtures

Critical

  • Tests receive page objects and API access through fixtures. new AppPage(page) inside a spec is forbidden.
  • Spec files import test and expect from fixtures/pom/test-options.ts, never from @playwright/test.
  • Page-object fixtures live in fixtures/pom/page-object-fixture.ts, lifecycle fixtures in fixtures/helper/helper-fixture.ts, functions without a lifecycle in helpers/ (helpers). No per-page fixture files.
  • Every fixture is typed in FrameworkFixtures or HelperFixtures.
  • Setup runs before await use(data), teardown after it. Code placed before use() never tears down.

    // CORRECT
    const user = await createUser();
    await use(user);
    await deleteUser(user.id);
    // WRONG: teardown before use() runs before the test
    await deleteUser(user.id);
    await use(user);
  • A new fixture category gets its own fixtures/<category>/<name>-fixture.ts and is merged into fixtures/pom/test-options.ts with mergeTests().
  • One-off API calls use apiRequest directly in the test. A helper fixture is only for setup and teardown that recurs past the threshold api-testing owns.
  • Fixture code parses API bodies with SchemaName.parse(body), never body as T. The expect(SchemaName.parse(body)).toBeTruthy(); form is for spec files.

Procedure

  1. Classify the need. Existing fixtures are the type literals FrameworkFixtures, ApiRequestMethods and HelperFixtures.

    NeedHome
    Page object injected into testsextend fixtures/pom/page-object-fixture.ts
    Recurring API setup/teardown with guaranteed cleanupextend fixtures/helper/helper-fixture.ts
    One-off API call in one test or describeno fixture; apiRequest in the test (api-testing)
    Reusable function with no lifecyclehelpers/ (helpers)
    Something else that needs page or request via DInew category: own file, merged with mergeTests()

    None of the rows fit → ask.

  2. Page object: add the property to FrameworkFixtures and the body async ({ page }, use) => { await use(new X(page)); }, shaped like appPage in the real file. No mergeTests change.
  3. Lifecycle fixture: add the type to HelperFixtures; write setup → use → teardown per references/lifecycle.md, calling apiRequest from fixtures/api/plain-function.ts with data from a factory (data-strategy) and the body parsed with the endpoint's schema before use.
  4. New category: file skeleton and the mergeTests() line per references/lifecycle.md.
  5. Run npx tsc --noEmit, then the spec that consumes the fixture.

References

  • references/lifecycle.md: the helper-fixture skeleton, the new-category file and merge, and the four symptoms of a mis-wired fixture.

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.