CtrlK
BlogDocsLog inGet started
Tessl Logo

testland/playwright-fixture-builder

Builds reusable Playwright fixtures via `test.extend` - picks the right scope (test vs worker), wires the `use(value)` setup/teardown split, composes auth (storageState per worker), database (per-test snapshot/restore), and feature-flag fixtures into one custom `test` object the whole suite imports. Outputs the `fixtures.ts` file plus per-fixture review notes (scope rationale, teardown ordering, `workerInfo.workerIndex` for parallel isolation). Use when the suite has copy-pasted `beforeEach` boilerplate that should be a fixture, or when adding auth / db / flag setup that crosses many specs.

75

Quality

94%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide

SecuritybySnyk

Passed

No findings from the security scan

Overview
Quality
Evals
Security
Files

anti-patterns-and-limits.mdreferences/

Anti-patterns and limitations

Anti-patterns

Anti-patternWhy it failsFix
Worker-scoped fixture for state that changes between testsTests on the same worker pollute each other; intermittent failures.Move to test scope. Per pw-fix: test-scoped fixtures "are torn down immediately after".
Test-scoped fixture for immutable expensive state (e.g. logged-in user)Per-test login = N × ~1s. CI time balloons.Worker scope + workerInfo.workerIndex per pw-fix.
beforeAll for shared state in a parallel suitebeforeAll runs once per spec file, not once per worker; doesn't compose.Worker-scoped fixture with the right use() boundary.
Teardown that depends on a downstream fixture's setupReverse-order teardown means the dependency is gone when teardown runs.Invert composition: dependent fixture extends the dependency.
Manual await context.close() inside a testBypasses Playwright's cleanup; flake on the next test.Let the page/context fixture handle close in its teardown.
Hard-coded port / DB name in fixturesTwo parallel workers fight over the same resource.Derive from workerInfo.workerIndex per pw-fix.
Storing playwright/.auth/*.json in gitPer pw-auth: "these files contain sensitive cookies and headers"..gitignore the auth dir; reauthenticate in CI per worker.
One mega-fixture that bundles auth+db+flagsTests can't opt out of pieces; one tweak breaks everyone.Atomic fixtures composed via extend per Step 6.

Limitations

  • No mid-test scope changes. A worker-scoped fixture can't be reset for one test without re-architecting; if mid-test reset is needed, the fixture should be test-scoped.
  • Session storage isn't auto-captured. Per pw-auth: "Manually persist session data since Playwright doesn't automatically capture it" - for sessionStorage-based auth, write custom serialization in the fixture.
  • Teardown failures don't fail the test. A throw inside the post-use() block produces a warning, not a failure. Wrap critical teardown in a runtime check that fails the next test if state is dirty.
  • Fixture timeout is per-fixture, not per-test. Long auth fixtures need { timeout: 60_000 }; the test's own timeout is separate.

SKILL.md

tile.json