agentleFS
sayurionishisayurionishi/playwright-scaffold/.claude/skills/fixtures/SKILL.md

fixtures

Skill1 starsChanged 3 months agoMITView on GitHub

Use when wiring a page object into dependency injection, sharing setup/teardown across tests, or adding a new fixture category. Defines the fixture layering and the single import point.

4 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. 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 2

    Distinctive

    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:

    Add await productsPage.goto() before use ONLY if every consumer starts on that page.

    line 29
  2. Very specific:

    Promotion rule: create a helper fixture only when the same setup/teardown is reused across 3+ files.

    line 44
  3. Distinctive:

    Don't put assertions in fixtures.

    line 53
  4. Distinctive:

    Don't share mutable state between tests via fixtures (breaks parallelism/independence).

    line 54

“Common” is measured: kept by at least 6 in 10 of the 3 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

Fixtures

Fixtures give auto-init and auto-cleanup. Three layers, merged into one import point.

fixtures/
├── api/    api-fixture.ts (the `api` client) + api-request.ts + schemas/
├── pom/    page-object-fixture.ts (page object DI)
├── helper/ helper-fixture.ts (setup/teardown lifecycle)
└── test-options.ts  ← mergeTests(...) — the ONLY thing specs import

Every spec: import { test, expect } from '<...>/fixtures/test-options'; Importing test from @playwright/test directly is a bug — it bypasses all custom fixtures.

Page-object fixtures

Register each page object once in pom/page-object-fixture.ts:

productsPage: async ({ page }, use) => { await use(new ProductsPage(page)); },

Add await productsPage.goto() before use ONLY if every consumer starts on that page. Tests then destructure { productsPage } — never new.

Helper fixtures (setup/teardown)

Setup → await use(data) → teardown. The teardown half runs even on failure, so data never leaks.

seededUser: async ({ request }, use) => {
  const user = await create(...);   // setup
  await use(user);
  await delete(user.id).catch(() => {});  // teardown, best-effort
},

Promotion rule: create a helper fixture only when the same setup/teardown is reused across 3+ files. Otherwise call api directly in the test — don't over-fixture.

New category

base.extend<MyFixtures>({...}) in its own file, then add it to the mergeTests(...) in test-options.ts.

Don't

  • Don't put assertions in fixtures.
  • Don't share mutable state between tests via fixtures (breaks parallelism/independence).

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.