playwright-best-practices

Apply Playwright best practices to fix flaky test behavior.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/stellarone/evaluate --skill playwright-best-practices-stellarone
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: playwright-best-practices
Source: https://github.com/stellarone/evaluate/tree/main/.agents/skills/playwright-best-practices
Command: npx skills add https://github.com/stellarone/evaluate --skill playwright-best-practices-stellarone

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill reduces flaky, slow, and hard-to-debug Playwright test suites by guiding you toward consistent patterns for selectors, waiting, structure, and CI reliability across E2E, component, and API testing.

Core Features & Use Cases

  • Deterministic test architecture: Choose solid test structure (E2E vs component vs API) and apply patterns like Page Object Model vs fixtures to keep suites maintainable.
  • Stable interactions: Use robust locator strategies and web-first assertions to minimize timing issues and brittle selectors.
  • Debugging and resilience: Diagnose flaky tests with traces/inspector guidance, handle timeouts, and capture console/JS errors to pinpoint root causes.
  • Coverage of real-world scenarios: Covers authentication flows (including OAuth and MFA), advanced browser APIs (geolocation/permissions/clipboard/camera), network and error handling, offline/recovery, file upload/download, multi-context/popups, i18n, accessibility (axe-core), security checks, visual regression, Electron apps, and browser extensions.
  • CI/CD optimization: Provides sharding, tagging, reporting, environment management, and test coverage strategies to keep pipelines efficient and trustworthy.

Quick Start

Use this Skill when you want targeted guidance to fix flaky Playwright tests by telling the AI: "Fix my flaky Playwright login flow and make the assertions stable using best practices."

Frequently Asked Questions about playwright-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix flaky Playwright tests caused by timing issues and brittle selectors?

Fix flaky Playwright tests by adopting robust locator strategies and web-first assertions. This ensures stable interactions by letting the browser handle waiting automatically, eliminating manual timeouts and brittle selector dependencies.

What is the best way to structure Playwright tests using Page Object Model vs fixtures?

The best way to structure Playwright tests involves choosing between the Page Object Model and custom fixtures for deterministic architecture. Using fixtures provides isolated test states, while Page Object Model centralizes selector logic for maintainable E2E suites.

How do I handle authentication and MFA flows in Playwright E2E tests?

Handle authentication and MFA flows in Playwright E2E tests by applying best practices for session storage and multi-factor authentication simulation. This captures authenticated states to reuse across tests, avoiding repeated logins and stabilizing complex OAuth workflows.

Can I run accessibility and visual regression checks with Playwright?

Yes, you can run accessibility and visual regression checks with Playwright. Integrating axe-core checks and visual comparison commands within your test suite detects UI regressions and a11y violations automatically during execution.

Why does my Playwright test suite fail in CI/CD pipelines but pass locally?

Playwright test suites fail in CI/CD but pass locally due to resource constraints or missing sharding strategies. Optimizing CI configuration with sharding, tagging, and proper environment management ensures reliable test execution and accurate reporting.

How do I debug Playwright test failures using traces and inspector?

Debug Playwright test failures using traces and the inspector to capture console errors and diagnose flaky behavior. This pinpoints root causes by providing detailed execution timelines, screenshots, and DOM snapshots for effective troubleshooting.