playwright-best-practices

Enforce Playwright best practices for TypeScript tests using @playwright/test.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you write maintainable, reliable Playwright tests by enforcing resilient locator strategies, web-first assertions, test isolation, and CI-friendly configuration to prevent context overflow.

Core Features & Use Cases

  • Enforces locator best practices by prioritizing roles, labels, placeholders, and visible text over brittle CSS selectors.
  • Promotes web-first assertions, fixtures-based setup, and storage-state reuse to speed up tests and improve reliability.
  • Provides concrete anti-pattern guidance (avoid timeouts, avoid UI-based login in every test, isolate tests, and configure minimal reporters in CI) and references the Playwright patterns reference for advanced techniques.

Quick Start

Always run Playwright tests with a minimal reporter in CI to prevent context overflow.

Frequently Asked Questions about playwright-best-practices

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

FAQPage Schema
What are the best locator strategies for Playwright tests?

Playwright locator strategies prioritize roles, labels, placeholders, and visible text over brittle CSS selectors to reduce test flakiness. Using resilient locators ensures tests remain maintainable and less prone to breaking during UI updates.

How do I reuse authentication state in Playwright tests?

Reuse authentication state in Playwright by saving and loading storage state instead of performing UI-based login in every test. This approach speeds up test execution and improves reliability through proper test isolation.

Why should I avoid page.waitForTimeout in Playwright?

Avoid page.waitForTimeout in Playwright because it introduces fixed delays causing brittle test patterns. Use web-first assertions instead to automatically wait for expected element states, improving test reliability and execution speed.

How do I configure Playwright reporters to prevent context overflow in CI?

Configure Playwright with minimal reporters in CI to prevent context overflow. Streamlining reporting output avoids memory issues during continuous integration runs while maintaining essential test feedback for automated pipelines.

Should I use fixtures or beforeEach for Playwright test setup?

Use fixtures over beforeEach for Playwright test setup to achieve better test isolation and reliable execution. Fixtures provide scoped setup and teardown, enabling flexible test composition without polluting global test context.

Does this Playwright best practices guidance work with TypeScript?

This Playwright best practices guidance applies to TypeScript Playwright tests using @playwright/test in CI and local development. It covers locator strategies, assertions, fixtures, authentication flows, and configuration for TypeScript environments.