Skip to content
Skills Library
Programming · Testing

ui-playwright

/ui-playwright

Writes Playwright UI tests — role locators, page objects, fixtures, network stubs, snapshot policy, one test per Storybook story state. Use when testing a screen, component, or user flow in a browser.

Repository
magus ↗
Licence
MIT
Last repository change
26.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 26.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Writes Playwright UI tests — role locators, page objects, fixtures, network stubs, snapshot policy, one test per Storybook story state. Use when testing a screen, component, or user flow in a browser.

Original author description

Writes Playwright UI tests — role locators, page objects, fixtures, network stubs, snapshot policy, one test per Storybook story state. Use when testing a screen, component, or user flow in a browser.

How it works

  1. Inputs and outputs
  2. Workflow
  3. Flake control
  4. Config for CI
  5. Verification before done
Original SKILL.md headings · 82 lines, 611 words
SKILL.md preview
---
name: ui-playwright
description: Writes Playwright UI tests — role locators, page objects, fixtures, network stubs, snapshot policy, one test per Storybook story state. Use when testing a screen, component, or user flow in a browser.
---

# UI tests with Playwright

Objective: a UI test suite that fails when a user-visible behaviour breaks and stays green
across runs. The contract is the Storybook story set and the spec; the implementation is
not an input.

## Inputs and outputs

| Input | Where it comes from |
|---|---|
| Story files (`*.stories.tsx`) | `CONTRACT_PATHS` — every exported story is a state to test |
| Spec | `SPEC_PATH` — flows, error text, limits |
| Test dir and config | `TEST_DIR`, `playwright.config.*` if present |

Output: `*.spec.ts` files under `TEST_DIR`, a `playwright.config.ts` if none exists, page
objects under `TEST_DIR/pages/`, fixtures under `TEST_DIR/fixtures/`.

## Workflow

1. **Map stories to tests.** For each story export write one test named
   `<Component> · <story> · <expected outcome>`. A story with no test is a gap; a test
   with no story or spec line is an implementation test — delete it.
2. **Locate by role, then label, then test id.** `getByRole('button', { name: 'Save' })`
   first; `getByLabel`, `getByText` next; `getByTestId` only when the element has no
   accessible name, and then record the id as a contract the component must keep. Never
   locate by CSS class or DOM position.
3. **Page objects for flows, not for single components.** A page object exposes actions
   (`login(user)`, `openOrder(id)`) and readable state (`errorText()`); it holds locators,
   nothing else. Component tests call the component directly through `@playwright/experimental-ct-react`
   (or the framework's CT package) with props from the story.
4. **Fixtures own setup and teardown.** Auth, seeded data, and viewport live in
   `test.extend` fixtures; a test body is arrange-act-assert only.
5. **Stub the network at the boundary.** `page.route()` for third-party and backend
   calls in component and flow tests; assert the request shape when the spec defines it.
   E2E tests against a real backend run in a separate project with its own tag.
6. **Assert observable outcomes.** Rendered text, `toBeVisible`, `toHaveValue`,
   `toHaveAttribute('aria-invalid', 'true')`, URL, emitted network request. Never assert
   on internal state, store shape, or that a handler was called.
7. **Snapshots are for layout regressions only.** One `toHaveScreenshot()` per story
   state, `maxDiffPixelRatio` set explicitly, masks for dates and avatars, stored per
   platform. A snapshot never replaces a behavioural assertion.
8. **Every state from the guardrails is a test.** Default, hover, focus, disabled,
   loading, invalid, empty — if the story exists, the test exists; if the story is
   missing, report it as a contract gap rather than skipping the state.

## Flake control

- Web-first assertions only (`expect(locator).toBeVisible()`); no `waitForTimeout`.
- `test.describe.configure({ mode: 'serial' })` only for flows that share a server-side
  state, and say why in a comment.
- `retries: 0` locally, `retries: 1` in CI with `trace: 'on-first-retry'`; a test that
  needs the retry is filed as a bug, not left green.
- Fixed viewport, fixed locale and timezone in the config; freeze `Date` through the
  fixture when the UI renders time.

## Config for CI

```ts
// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
  testDir: './tests/ui',
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 1 : 0,
  reporter: process.env.CI ? [['github'], ['html', { open: 'never' }]] : 'list',
  use: { trace: 'on-first-retry', locale: 'en-US', timezoneId: 'UTC', viewport: { width: 1280, height: 800 } },
  projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
  webServer: { command: 'bun run dev', url: 'http://localhost:5173', reuseExistingServer: !process.env.CI },
});
```

Run headless with `bunx playwright test`; `bunx playwright install --with-deps chromium`
once per CI image.

## Verification before done

- Every story export appears in a test name (grep the stories dir against `TEST_DIR`).
- `bunx playwright test` passes twice in a row locally.
- Negative control: change one expected string in one test, watch it fail, restore it.

Versions

The database has no other skills named ui-playwright.

Database snapshot: 13.11.2026 · package version a4422095dc6b (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 95qa-e2e-playwright
    Use this skill when the user says 'playwright', 'playwright test', 'playwright config', 'locators', 'storageState', 'trace viewer', 'playwright codegen', 'playwright sharding', 'playwright fixtures'. It writes and structures Playwright Test suites in TypeScript: config,…
  • 95frontend-playwright-testing
    Use this skill when the user says 'Playwright test', 'write an E2E test', 'component test with Playwright', 'flaky e2e', 'getByRole locator', 'Playwright auth setup', 'storageState', 'trace viewer', 'Playwright CI sharding'. It writes resilient Playwright end-to-end and…
  • 82playwright
    Playwright E2E testing standards — test structure, selectors, fixtures, page objects, CI integration, and MCP runner so tests can be triggered from prompts. Load when writing, reviewing, or running Playwright specs.
  • 100playwright-testing
    Use when writing Playwright E2E tests — browser automation, visual regression testing, Page Objects, fixtures, and reliable test patterns.
  • 100playwright-e2e-testing
    Write, fix, or review Playwright end-to-end tests, especially for Next.js apps - locators, auth via storageState, flaky waits, server-side fetch mocking, CI against a production build. Use for *.spec.ts / e2e/ / playwright.config changes or flaky browser tests. For unit and…
  • 100playwright-testing
    UI/E2E test automation with Playwright MCP. Use when the user asks to "test the UI", "automate browser tests", "check the page", "take a screenshot", "run Playwright", "write E2E tests", or anything about browser-based testing.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.