Skip to content
Back to skills

Playwright

ASecurity

Playwright E2E tests: page objects, cross-browser projects, traces and CI setup. Use when writing or debugging Playwright specs, or configuring Playwright in CI.

  • 80 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added May 28, 2026
ai-agentsgobashtestingdebuggingapi

Works with

  • api

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned October 5, 2026

npx -y skills add monkilabs/opencastle --skill playwright-testing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Playwright?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Playwright
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/monkilabs-playwright/badge)](https://www.skillsdirectory.com/skills/monkilabs-playwright)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: playwright-testing
description: "Playwright E2E tests: page objects, cross-browser projects, traces and CI setup. Use when writing or debugging Playwright specs, or configuring Playwright in CI."
---

# Playwright Testing

Project test config and breakpoints: `.opencastle/stack/testing-config.md`. Docs: https://playwright.dev/docs/intro

Layout: specs `tests/e2e/{feature}/`, page objects `tests/pages/`, fixtures `tests/fixtures/`.

## Locator priority

`getByRole(role, { name })` → `getByLabel()` for inputs → `getByTestId()` for containers → `getByText()` → `page.locator(css)` **only** when no semantic alternative exists.

## Gotchas

- Page objects must hold no module-level/global state. Parallel workers share the process, so a singleton leaks state between tests and produces order-dependent failures.
- `trace: 'on-first-retry'` costs nothing on green runs — enable it for flaky suites and attach the trace ID to failure tickets.
- Visual diffs: snapshot only stable regions and `mask` dynamic content, otherwise every run diffs.
- `forbidOnly: !!process.env.CI` prevents a stray `test.only` from silently shrinking the CI suite to one test.
- `webServer.reuseExistingServer: !process.env.CI` — locally reuses your dev server; in CI it must start its own.
- `retries: 2` and `workers: 1` in CI trade wall-clock for determinism.
- Mock at the network layer: `await page.route('/api/login', route => route.fulfill({ status: 200, body: ... }))`.

## Commands

```bash
npx playwright test --ui                      # interactive iteration
npx playwright test auth.spec.ts              # single spec
npx playwright test --project=chromium        # one browser
npx playwright test --grep "login"            # filter by title
npx playwright test --debug                   # step through
npx playwright codegen http://localhost:3000  # record a spec
npx playwright show-report                    # HTML report (verify 0 failures)
npx playwright install                        # browsers — required on a fresh machine/CI
```

`projects` in `playwright.config.ts` map to `devices[...]` presets (`Desktop Chrome`, `Desktop Firefox`, `Desktop Safari`, `iPhone 14`).

Files in this skill

  • REFERENCE.md507 B
  • SKILL.md4.3 KB
  • config.ts711 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…