Playwright architect

From event4u-app/agent-config · View interactive version

Playwright architect is an AI agent skill from the GitHub repository event4u-app/agent-config. Use when shaping a Playwright suite — locator strategy, Page Object boundaries, fixture composition, flake-prevention architecture, CI-vs-local split — even on 'design our E2E tests'.

How to use this skill

Skill file

playwright-architect

Architectural lens above the existing tactical

CODE0. Decides

locator philosophy, Page Object boundaries, fixture composition,

and the CI-vs-local split before the first test is written.

The playwright-testing skill handles concrete assertions,

selectors, and visual-regression mechanics once the design is

locked.

When to use

hierarchy, and locator strategy are unsettled.

god-test file mixing unrelated journeys.

to share fixtures with the main suite.

"warum flaket der Test?".

Do NOT use when:

— route to CODE0.

CODE0.

tool; route to the stack-specific testing skill.

Procedure

1. Inspect the suite, pick the locator philosophy

Review existing tests for current locator patterns; the established

strategy wins unless it is the "last resort" tier. One philosophy

per suite, written into CONTRIBUTING-tests.md:

| Strategy | When |

|---|---|

| getByRole + accessible name | Default — couples tests to the user contract, not markup |

| data-testid | Legacy markup, third-party widgets, hash-suffixed CSS modules |

| Text content (getByText) | Static marketing pages, copy-stable surfaces |

| CSS / XPath | Last resort — every use is a debt entry |

Mixing strategies inside one test file is the smell — pick one and

fall back only with comment.

2. Cut Page Object boundaries

A Page Object owns: (a) one URL or one logical surface (modal,

drawer), (b) the locators on that surface, (c) the actions a

user can perform there. It does NOT own assertions about other

surfaces or test setup. Boundary rule: if two POs need to call

each other, introduce a flow object (SignupFlow) above them.

3. Compose fixtures, don't inherit

Playwright fixtures stack via test.extend(). Three layers max:

| Layer | Owns |

|---|---|

| Base | Browser, context, storageState, network mocks |

| Auth | Logged-in user states (admin, member, guest) |

| Domain | Pre-seeded entities for a journey |

Deeper stacks become un-debuggable; flatten by extracting helpers.

4. Plan flake prevention before the first failure

Bake in: auto-retry on network idle, soft assertions for parallel

checks, deterministic seed data, time freezing (page.clock),

explicit expect.poll() for eventual consistency, no

waitForTimeout ever. If a test needs sleep, the fixture is

wrong.

5. Split CI vs local execution

Local: headed browser, single worker, slowMo enabled, video off,

trace-on-retry. CI: headless, sharded workers (2–8), trace-on-first-retry,

video-on-failure, Github reporter + HTML. Document both in

playwright.config.ts; do not let local config leak into CI.

Output format

Return:

  1. Locator + Page Object plan — chosen strategy, PO list with surface

and action count, flow objects when ≥ 2 POs collaborate.

  1. Fixture composition — base / auth / domain layer with what each

layer sets up.

  1. Parallelism + flake budget — worker count, shard strategy,

isolation, target flake ceiling, CI-vs-local config delta.

Concrete shape:

Suite:            <name>
Locator strategy: <getByRole | data-testid | text | mixed (justified)>
Page Objects:     <list with surface owned + action count>
Flow objects:     <list — only when ≥ 2 POs collaborate>
Fixture layers:   base / auth / domain — each with what it sets up
Parallelism:      <workers, shards, isolation strategy>
Flake budget:     ≤ 1 % failure on green main; alert threshold
CI-vs-local:      <key config delta, one bullet each>

Gotcha

has built-in retry. The former teaches devs to think "wait, then

assert" instead of "auto-retry assertion".

isolation; the same auth.json across two browsers in parallel

shares a session and corrupts state.

pin the Docker image, never run visual tests against host

Chromium.

for SPA routes; cut by user surface, not by pathname.

Do NOT

in the same step — they sit at different tiers; pick one per phase.

Playwright Component Testing has different fixture rules; route

there instead.

metric. Zero is a goal that disguises silent retries.

is a design note for refinement, not implementation steps.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.