playwright-fixture-builder
БесплатноБез исполняемых скриптовНе проверенUse for any question or task about sharing setup across Playwright tests, including reusing login, copy-pasted beforeEach blocks, and test users that collide…
от testland★ 18 звёзд на GitHubОб этом скилле
playwright-fixture-builder
Overview
Playwright Test fixtures replace beforeEach / afterEach
boilerplate with composable, lazy-initialized values that hang off
the test function (pw-fixtures).
This skill is build-an-X - it produces the fixtures.ts (or
language-equivalent) file from the team's actual setup needs (auth,
database state, feature flags, app instance), picking the right
scope and teardown ordering for each.
When to use
- Multiple spec files copy-paste
beforeEach/afterEachsetup blocks that should be a fixture. - A new test suite needs auth + DB + flags wired and the team wants
one cohesive
fixtures.tsrather than ad-hoc helpers. - An existing suite is slow because each test re-authenticates; there's a worker-scope shortcut available.
- The team is adding parallelism and current fixtures don't honor
workerInfo.workerIndexfor per-worker isolation.
If the suite has only a handful of specs and one common helper, a
shared helpers.ts file is enough - fixtures pay off when 5+ specs
share setup or when teardown ordering matters.
How to use
- List every
beforeEach/afterEachblock the specs share (auth, DB reset, flag setup, page objects). - Assign each a scope with Step 1's rule of thumb -
workerfor immutable expensive state,testfor anything that changes between tests. - Write each fixture with the
use(value)setup/teardown split - recipes for auth, page object, DB, and flags are in references/fixture-recipes.md. - Compose them in dependency order (auth → db → flags) into one
testexport; see references/composition-and-output.md. - Confirm teardown runs in reverse of setup, and box internal helper fixtures out of the report.
- Replace the specs' copy-pasted blocks with a single import from
the composed
fixtures/index.ts. - Emit the per-fixture review note (scope, auto, boxed, setup cost, teardown) so a reviewer can sanity-check the scoping.
Step 1 - Identify the right scope per fixture
Fixtures are test-scoped by default (run and torn down per test);
declare { scope: 'worker' } for state shared across a worker's tests
(pw-fixtures). The table assigns a scope per fixture.
| Fixture | Scope | Why |
|---|---|---|
| Authenticated user | worker |
Auth handshake is expensive (UI login, cookie set, OTP); state is shareable. |
| Storage-state file path | worker |
One storageState per worker keeps server-side cohorts isolated. |
| Page object (TodoPage) | test |
Each test needs a clean DOM and navigation start. |
| Test-DB snapshot | test |
Per-test isolation requires per-test restore. |
| Feature-flag overrides | test |
Different tests may want different flag combos (compose with feature-flag-test-harness). |
| Browser instance | worker |
(Playwright default) - sharing cuts ~500ms per test. |
| Test-data factory | test |
Each test gets fresh fixtures with worker-namespaced IDs. |
Rule of thumb: if changing the fixture between two tests would
cause a test to fail, scope it test. Otherwise scope it worker.
Fixture recipes, composition, output
A complete worker-scoped storageState auth fixture - signs in once
per worker and reuses the cookie / localStorage snapshot across that
worker's tests:
// fixtures/auth.ts
import { test as base } from '@playwright/test';
import path from 'node:path';
export const test = base.extend<{}, { storageState: string }>({
storageState: [async ({ browser }, use, workerInfo) => {
const username = `user${workerInfo.workerIndex}`;
const fileName = path.resolve(`playwright/.auth/${username}.json`);
const page = await browser.newPage({ storageState: undefined });
await page.goto('/login');
await page.getByLabel('Email').fill(`${username}@example.com`);
await page.getByLabel('Password').fill('test-password');
await page.getByRole('button', { name: 'Sign in' }).click();
await page.waitForURL('/dashboard');
await page.context().storageState({ path: fileName });
await page.close();
await use(fileName);
}, { scope: 'worker' }],
});
- The remaining recipes - page object, DB snapshot/restore, and feature-flag overrides: references/fixture-recipes.md.
- Composing the layers into one
testexport, teardown ordering, boxing internal fixtures, and the review-note output format: [references/composition-an
Установить playwright-fixture-builder в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл playwright-fixture-builder?
Use for any question or task about sharing setup across Playwright tests, including reusing login, copy-pasted beforeEach blocks, and test users that collide between parallel workers. Builds test.extend fixtures with the right test or worker scope, setup and teardown, and per-worker isolation for login, database or feature-flag setup.
Как установить скилл playwright-fixture-builder?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл playwright-fixture-builder запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic