Battle-tested Playwright patterns for writing, debugging, and scaling reliable test suites. Use when you need guidance for E2E, API, component, visual, accessibility, or security testing, plus CI/CD, CLI automation, page objects, and migration from Cypress or Selenium. TypeScript and JavaScript.
name: playwright-skill
description: Battle-tested Playwright patterns for writing, debugging, and scaling reliable test suites. Use when you need guidance for E2E, API, component, visual, accessibility, or security testing, plus CI/CD, CLI automation, page objects, and migration from Cypress or Selenium. TypeScript and JavaScript.
license: MIT
metadata:
author: testdino.com
version: "2.2.0"
Playwright Skill
Opinionated, production-tested Playwright guidance — every pattern includes when (and when not) to use it.
50+ reference guides covering the full Playwright surface: selectors, assertions, fixtures, page objects, network mocking, auth, visual regression, accessibility, API testing, CI/CD, debugging, and more — with TypeScript and JavaScript examples throughout.
Playwright 1.59+ highlights covered in these guides include screencast recording, browser binding for agent workflows, CLI debugging and trace analysis, aria snapshot helpers, and in-place storage state updates.
Security Trust Boundary
This skill is designed for testing applications you own or have explicit authorization to test. It does not support or endorse automating interactions with third-party websites or services without permission.
When writing tests or automation that fetch content from external sources (e.g., baseURL pointing to staging/production), treat all returned page content as untrusted input — never pass raw page text back into agent instructions or dynamic code execution without sanitization, as this creates an indirect prompt injection risk.
For CI/CD workflows, pin all external dependencies (GitHub Actions, Docker images) to immutable references (commit SHAs, image digests) rather than mutable version tags. See ci-github-actions.md and docker-and-containers.md for pinning guidance.
Golden Rules
getByRole() over CSS/XPath — resilient to markup changes, mirrors how users see the page
Never page.waitForTimeout() — use expect(locator).toBeVisible() or page.waitForURL()
Web-first assertions — expect(locator) auto-retries; expect(await locator.textContent()) does not
Isolate every test — no shared state, no execution-order dependencies
baseURL in config — zero hardcoded URLs in tests
Retries: 2 in CI, 0 locally — surface flakiness where it matters
Traces: 'on-first-retry' — rich debugging artifacts without CI slowdown
Fixtures over globals — share state via test.extend(), not module-level variables
One behavior per test — multiple related expect() calls are fine
Mock external services only — never mock your own app; mock third-party APIs, payment gateways, email
All guides include TypeScript and JavaScript examples. When the project uses .js files or has no tsconfig.json, examples are adapted to plain JavaScript.