playwright-cursor-rules

Guides writing Playwright end-to-end tests with TypeScript and JavaScript best practices.

Updated Mar 18, 2026
One-click install
npx skills add https://github.com/Surojit012/CMO --skill playwright-cursor-rules-surojit012
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: playwright-cursor-rules
Source: https://github.com/Surojit012/CMO/tree/main/.agents/skills/playwright-cursor-rules
Command: npx skills add https://github.com/Surojit012/CMO --skill playwright-cursor-rules-surojit012

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing maintainable, reliable end-to-end tests is hard: flaky selectors, hardcoded timeouts, and poor test isolation cause unstable suites. This Skill provides expert Playwright guidance so tests follow proven TypeScript and JavaScript best practices from the start. ## Core Features & Use Cases - Locator Strategy Guidance: Prioritizes role-based locators like page.getByRole and page.getByLabel over brittle CSS selectors. - Test Structure Standards: Enforces fixtures, test.beforeEach/test.afterEach setup, web-first assertions, and parallel-safe test design. - Use Case: When asked to write a login flow test, the Skill produces a spec using playwright.config.ts projects, descriptive test names, web-first assertions like toBeVisible, and no hardcoded waits. ## Quick Start Ask the assistant to write a Playwright end-to-end test for a specific user flow in your application.

Frequently Asked Questions about playwright-cursor-rules

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

FAQPage Schema
How do I write Playwright tests with TypeScript best practices?

Use Playwright fixtures like test, page, and expect for isolation, write descriptive test names, and prefer web-first assertions such as toBeVisible and toHaveText. Extract reusable logic into helper functions and configure global settings in playwright.config.ts.

What locators should I use in Playwright tests?

Prioritize role-based locators like page.getByRole, page.getByLabel, and page.getByText over complex CSS or XPath selectors. Use page.getByTestId when data-testid attributes exist in the application markup.

How do I run Playwright tests across multiple browsers?

Define projects in playwright.config.ts using built-in device descriptors from the devices object. Each project targets a browser or device profile, letting one test suite run across Chromium, Firefox, WebKit, and mobile viewports.

Why are my Playwright tests flaky and how do I fix them?

Flakiness usually comes from hardcoded timeouts, shared state between tests, or brittle selectors. Replace fixed waits with page.waitFor conditions or web-first assertions, isolate tests with beforeEach hooks, and avoid shared state so tests run reliably in parallel.

Should I use assert or expect in Playwright tests?

Use Playwright's expect with web-first assertions like toBeVisible and toHaveText instead of generic assert statements. Web-first assertions auto-retry until conditions are met, reducing timing-related failures.