playwright-testing
Skill0 starsChanged 49 days agoMITView on GitHub
Playwright end-to-end testing rules for writing, reviewing and de-flaking browser tests - role-based locators, web-first assertions, isolated tests with fixtures and storageState, a flaky-test taxonomy and proof-of-fix, and review anti-patterns. Use when writing or reviewing Playwright tests, setting up Playwright, or fixing a failing or flaky e2e test.
- Reads credentials
18 other projects use a version of this.
Adopted by
Most recently taken up by
- kazemcodes/skill-treetheir own version, first seen Nov 8, 2026
- n-n-code/n-n-code-skillstheir own version, first seen Nov 1, 2026
- TangleML/tangle-uitheir own version, first seen Oct 8, 2026
- PrairieLearn/PrairieLearntheir own version, first seen Oct 8, 2026
- fossasia/visdomtheir own version, first seen Oct 8, 2026
- alinaqi/claude-bootstraptheir own version, first seen Oct 8, 2026
Used with
Projects with it also use security, ponytail and 1 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
0xSeroSkillsecurity
Also in 3 projects that use this
GoogleSkillponytail
Forces the laziest solution that actually works, simplest, shortest, most minimal. Channels a senior dev who has seen everything: question whether the task needs to exist at all (YAGNI), reach for the standard library before custom code, native platform features before dependencies, one line before fifty. Supports intensity levels: lite, full (default), ultra. Use on ANY coding task: writing, adding, refactoring, fixing, reviewing, or designing code, and choosing libraries or dependencies. Also use whenever the user says "ponytail", "be lazy", "lazy mode", "simplest solution", "minimal solution", "yagni", "do less", or "shortest path", or complains about over-engineering, bloat, boilerplate, or unnecessary dependencies. Do NOT use for non-coding requests (general knowledge, prose, translation, summaries, recipes).
Also in 3 projects that use this
GoogleSkillgrill-me
A relentless interview to sharpen a plan or design.
Also in 3 projects that use this
Other versions18 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 18
- fossasia/visdom★ 10ksame name
- podman-desktop/podman-desktop★ 8.1ksame name
- silvertakana/worldwideview★ 1.9ksame name
- marmelab/atomic-crm★ 1.4ksame name
- alinaqi/maggy★ 711same name
- alinaqi/claude-bootstrap★ 708same name
- PrairieLearn/PrairieLearn★ 530same name
- Community-Access/accessibility-agents★ 409same name
- chongdashu/vibejam-starter-pack★ 147same name
- TangleML/tangle-ui★ 104same name
8 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository2 other files it gives its agents.
- freezeSkill
- team-buildSkill
The file
We split this skill into the rules it gives an agent
10 rules. 0 are common, 4 are distinctive, and 6 are very specific to this project.
0
Common
Most of the 17 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Isolate every test: No shared mutable state and no dependence on execution order (tests run in parallel).
- Very specific: line 19
Test failure paths: Every main journey has at least one error path, such as page.route('/api/x', r => r.fulfill({ status: 500 })) showing …
- Very specific: line 23
Use the first one that works (details and a role cheat sheet in references/locators.md):
- Very specific: line 34
Use a page object for a page with 5 or more locators.
- Distinctive: line 35
Keep test data in fixtures or factories, not magic strings spread across tests.
- Very specific: line 36
Use at most 2 levels of test.describe().
- Very specific: line 38
Add toHaveScreenshot() only for visually critical components, at a pinned viewport.
- Very specific: line 51
Add .auth/ and test-results/, playwright-report/ to .gitignore.
- Distinctive: line 72
Reviewers report fixes and don't apply them: When reviewing someone else's tests (code-reviewer, verifier), list the fixes and don't edit.
- Distinctive: line 74
Stay in your own files: Test files and test config only, per the ownership table.
“Common” is measured: kept by at least 6 in 10 of the 17 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Playwright testing
Ported from claude-skills' playwright-pro (MIT, (c) 2025 Alireza Rezvani, https://github.com/alirezarezvani/claude-skills), adapted to this team's rules. The reference files in references/ are copied from it unchanged. Where they disagree with the Team overrides below, the overrides win.
Golden rules
- Locate by role first.
getByRole()over CSS or XPath: it survives markup changes and mirrors assistive technology. Full priority list below. - Never
page.waitForTimeout(), and neverwaitForLoadState('networkidle'). Wait for something the user would see (await expect(locator).toBeVisible()), for a URL (await expect(page).toHaveURL(...)), or for a specific response (page.waitForResponse('**/api/x'), started before the action that triggers it). - Use web-first assertions.
await expect(locator)...retries until timeout.expect(await locator.textContent())andexpect(await locator.isVisible())check once and flake. - Isolate every test. No shared mutable state and no dependence on execution order (tests run in parallel). Create each test's data through the API or a fixture, and make identifiers unique.
- Put
baseURLin the config and use relativepage.goto('/login'). Never hardcode a host. - Use fixtures, not globals. Share setup with
test.extend(). Log in once with a setup project plusstorageState, not through the UI in every test (seereferences/fixtures.md). - One behaviour per test. Several related assertions are fine. Name the test after the behaviour and the AC (
AC-3: shows an error when the email is invalid). - Mock only what you don't own. Third-party APIs, payment gateways and email are mocked with
page.route(). Your own app and API are never mocked in e2e tests. - Test failure paths. Every main journey has at least one error path, such as
page.route('**/api/x', r => r.fulfill({ status: 500 }))showing the error state. Also cover empty states and permission-denied cases. - Always await. A missing
awaiton a Playwright call causes random passes.
Locator priority
Use the first one that works (details and a role cheat sheet in references/locators.md):
getByRole('button', { name: 'Save' }): buttons, links, headings, form controls, dialogs, tablesgetByLabel('Email address'): labelled form fieldsgetByText('Welcome back'): non-interactive textgetByPlaceholder(),getByAltText(),getByTitle()getByTestId('checkout-summary'): only when no semantic option existspage.locator(css): last resort. If you need it for an interactive control, the control is probably missing an accessible name, which is an accessibility bug to report.
Narrow with .filter({ hasText }), .filter({ has }) and chaining (getByRole('navigation').getByRole('link', { name: 'Settings' })).
Structure
- Use a page object for a page with 5 or more locators. Page objects expose intent (
login(email, password)) and use the locators above. - Keep test data in fixtures or factories, not magic strings spread across tests.
- Use at most 2 levels of
test.describe(). Split tests over about 50 lines. - Collect console errors:
page.on('console', m => m.type() === 'error' && errors.push(m.text())), then assert the list is empty for main journeys. - Add
toHaveScreenshot()only for visually critical components, at a pinned viewport.
Config (starting point)
export default defineConfig({
use: { baseURL: process.env.BASE_URL ?? 'http://localhost:3000', trace: 'on-first-retry', screenshot: 'only-on-failure' },
retries: process.env.CI ? 1 : 0, // see Team overrides
forbidOnly: !!process.env.CI, // a stray test.only fails CI
webServer: { command: 'npm run start', url: 'http://localhost:3000', reuseExistingServer: !process.env.CI },
projects: [{ name: 'setup', testMatch: /.*\.setup\.ts/ },
{ name: 'chromium', use: { storageState: '.auth/user.json' }, dependencies: ['setup'] }],
});Add .auth/ and test-results/, playwright-report/ to .gitignore. Upload the report and traces as CI artifacts on failure.
Flaky tests
Flaky tests are bugs. Diagnose them with references/flaky-taxonomy.md:
| Category | Signature | Typical fix |
| Timing/async | fails with --repeat-each=20 locally | web-first assertions, wait for the specific response, add the missing await |
| Isolation | passes alone (--workers=1 --grep), fails in the suite | per-test data, clear storage, isolated contexts |
| Environment | fails in CI only | pinned viewport, UTC, fonts; mock external services |
| Infrastructure | random browser crashes, OOM | fewer workers, more memory |
Capture a trace with --trace=on --retries=0, fix the cause, then prove the fix: npx playwright test <file> --repeat-each=10 must pass 10/10. Put that run's output in your report. One green run is not proof.
Review checklist (for your own tests and for reviewing others')
Critical: waitForTimeout or networkidle, non-web-first assertions, hardcoded URLs, CSS or XPath where a role exists, a missing await, shared mutable state, order dependence, test.only, a mock of your own app.
Warning: tests over 50 lines, generic names, no error or empty-state case, page.evaluate() where a locator would do, describe nested deeper than 2, magic strings.
Info: a page with 5 or more locators and no page object, no console-error check on main journeys, no accessibility assertion on key controls.
Details and examples are in references/anti-patterns.md and references/common-pitfalls.md.
Team overrides (these win over the references)
- Retries don't make a test pass. CI may use
retries: 1only so a trace gets captured. A test that passes only on retry is reported as FLAKY with its attempt count and fixed as a bug. Never raise retries to get green. Where the references say "add retries: 2", ignore it. - Reviewers report fixes and don't apply them. When reviewing someone else's tests (code-reviewer, verifier), list the fixes and don't edit. playwright-pro's "apply fixes" step doesn't apply here.
- Prove that new tests can fail (test-engineer rule): run each new test against the base commit in a temporary worktree and show it failing.
- Stay in your own files. Test files and test config only, per the ownership table.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

