writing-playwright-e2e-tests
/writing-playwright-e2e-tests
Opisuje standard testów E2E w Playwright: mapowanie kryteriów na scenariusze, Page Object, lokatory widoczne dla użytkownika i ograniczone limity debugowania.
- Autor
- thesoftwarehouse ↗
- Repozytorium
- agentic-collections ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 27.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 3
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 27.10.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Opisuje standard testów E2E w Playwright: mapowanie kryteriów na scenariusze, Page Object, lokatory widoczne dla użytkownika i ograniczone limity debugowania.
Oryginalny opis (EN)
TSH's standard for Playwright end-to-end tests: mapping acceptance criteria to scenarios, Page Object structure, user-visible locators, auto-waiting instead of manual timeouts, unique test data for parallel runs, mocking only external boundaries, and a bounded debug loop with explicit iteration limits and flake detection. Use when writing, debugging, reviewing or de-flaking E2E tests.
Jak działa
- Applicability and Precedence
- Non-negotiable Rules
- Reference Loading
- Map criteria to scenarios first
- Naming
- Procedure
- Output
- Anti-Patterns
- Related skills in this plugin
Podgląd SKILL.md
---
name: writing-playwright-e2e-tests
description: "TSH's standard for Playwright end-to-end tests: mapping acceptance criteria to scenarios, Page Object structure, user-visible locators, auto-waiting instead of manual timeouts, unique test data for parallel runs, mocking only external boundaries, and a bounded debug loop with explicit iteration limits and flake detection. Use when writing, debugging, reviewing or de-flaking E2E tests."
when_to_use: "Trigger on: writing E2E or Playwright tests for a feature or acceptance criteria, a flaky test that passes sometimes, a test failing on a timeout or a locator that cannot be found, creating or refactoring Page Objects, deciding what to mock in an E2E test, making a suite CI-ready or headless-safe, reviewing E2E tests before merge, or a plan task whose Definition of Done includes end-to-end coverage."
---
# Writing Playwright E2E Tests
A test earns its place by catching a real bug and never crying wolf. Four properties
carry that: reliable (never flaky), maintainable (Page Objects), fast (parallel-safe),
and meaningful (asserts what a user would notice).
## Applicability and Precedence
**The project's existing test conventions outrank this skill.** Before writing
anything, establish them:
- `playwright.config.ts` — projects, base URL, retries, reporters, viewport
- Existing Page Objects — the directory (`pages/`, `pom/`, `e2e/pages/`) and whether
they use getters, methods, or fixtures
- Locator strategy already in use, and any `data-testid` convention
- Fixtures and setup files — auth state, seeding, per-test isolation
- The test scripts in `package.json`, and the Playwright version to search docs against
When a `*.plan.md` exists, its Technical Context section is the primary source — it
records conventions already discovered, so do not re-derive them.
## Non-negotiable Rules
| Severity | Rule |
| --- | --- |
| MUST | Use user-visible locators — `getByRole`, `getByLabel`, `getByText`. `getByTestId` only where no user-visible locator is feasible. |
| MUST | Rely on Playwright's auto-waiting assertions. A test that needs a manual delay to pass is a test that will fail in CI. |
| MUST | Generate unique test data per run so tests are parallel-safe — e.g. `test-${Date.now()}-${test.info().parallelIndex}`. |
| MUST | Verify a new or fixed test with **3+ consecutive passes in headless mode** before reporting it done. One green run proves nothing about flake. |
| MUST | Read credentials from environment variables. Never hardcode them, never commit them, never print them. |
| MUST | Mark a test that fails because the *application* is broken as `test.fixme('BUG: <description>')` and report the bug. Never bend the test to make a real defect pass. |
| NEVER | Use `waitForTimeout()`, or `waitForLoadState('networkidle')` — both are flake sources. Wait for a specific element or response instead. |
| NEVER | Use CSS class or XPath selectors that couple the test to implementation detail. |
| NEVER | Let one test depend on state another test left behind. |
| NEVER | Mock the application's own API to make a test pass. Mock only genuinely external third-party boundaries. |
## Reference Loading
| Reference | Load when | Covers |
| --- | --- | --- |
| [Locators, data and mocking](./references/locators-and-anti-flake.md) | Writing any test or Page Object | Locator priority with examples, auto-waiting, test data isolation, what may and may not be mocked |
| [Debugging and the verification loop](./references/debugging-and-verification-loop.md) | A test is failing, flaky, or newly written and unverified | The bounded debug loop, iteration limits, per-error recovery, flake detection, CI readiness |
Read [debugging-and-verification-loop.md](./references/debugging-and-verification-loop.md)
before starting a fix loop — the iteration limits exist to stop an unbounded chase, and
that is the failure mode this skill most often prevents.
## Map criteria to scenarios first
Before writing a line, produce this table:
| Acceptance criterion | Scenario type | Test name |
| :-- | :-- | :-- |
| *from the plan, ticket, or prompt* | Happy / Error / Edge | `should <behavior> when <condition>` |
Then confirm:
- [ ] Every criterion maps to at least one test
- [ ] External boundaries needing a mock are listed
- [ ] Page Objects to create or extend are listed
Coverage is judged against this table, so an unmapped criterion is a gap you name
rather than discover at review.
## Naming
`should <behavior> when <condition>` — `should display an error when login fails`. The
name is the failure message a colleague reads in CI output at 9am; it should say what
broke without opening the file.
## Procedure
1. **Establish context** — the section above, plus the plan's Technical Context.
2. **Map criteria to scenarios** using the table.
3. **Explore the running app** to confirm locators before committing to them. The
Playwright MCP bundled with this plugin operates on the accessibility tree, which is
exactly the view `getByRole` resolves against — so what you see there is what your
locator will match. Requires the dev server running.
4. **Write Page Objects, then tests**, following the project's existing shape.
5. **Run and iterate** under the bounded loop in
[debugging-and-verification-loop.md](./references/debugging-and-verification-loop.md).
6. **Confirm stability** — 3+ consecutive headless passes.
7. **Check CI readiness** and report.
Look up Playwright API detail with `context7` against the version in `package.json`.
For Playwright specifically, query the library ID `/microsoft/playwright.dev` directly
rather than resolving it first.
## Output
```markdown
## E2E Test Summary
### Coverage
| Criterion | Test | Status |
|---|---|---|
Coverage: X/Y
### Results
| File | Pass | Fail | Flaky | Headless |
|---|---|---|---|---|
### Issues
- BUG: <description> → `test.fixme()`, needs an application fix
- FLAKY: <description> → what was tried, what is still suspected
### Files
```
Report honestly. A suite with two `test.fixme()` markers and a named bug is a better
outcome than a green suite that asserts nothing.
## Anti-Patterns
| Don't | Do |
| :-- | :-- |
| `waitForTimeout(2000)` | Assert on the element or response you are waiting for |
| `.btn-primary`, XPath | `getByRole('button', { name: 'Submit' })` |
| Shared fixture data across tests | Unique data per test run |
| Mock your own API to go green | Mock third-party boundaries only |
| Weaken an assertion to pass | `test.fixme()` and report the bug |
| One green run means done | 3+ consecutive headless passes |
| A test per UI element | A test per user-visible behavior |
| Helpers and Page Objects for tests not yet needed | Only what the current scope requires |
## Related skills in this plugin
- [Auditing accessibility](../auditing-accessibility/SKILL.md) — the accessibility tree
your role-based locators depend on is the same one an audit examines
Pliki w paczce (3)
- SKILL.md 7 KB
- references/debugging-and-verification-loop.md 4 KB
- references/locators-and-anti-flake.md 5 KB
Wersje
W bazie nie ma innych skilli o nazwie writing-playwright-e2e-tests.
Migawka bazy z 13.11.2026 · wersja paczki 3004ec52ce0c (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 2 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 90e2e-playwright
Projektuje testy e2e w Playwright: konfigurację równoległą, Page Object Model, lokatory semantyczne, reużycie sesji i wykrywanie niestabilnych testów. - 95e2e-test-writer
Pisze testy end-to-end w Playwright ze wzorcem page object model dla przepływów użytkownika w przeglądarce. - 100playwright-testing
Prowadzi pisanie testów end-to-end w Playwright Test: lokatory, asercje, mockowanie żądań sieciowych, uwierzytelnianie i konfigurację test runnera. - 100playwright-automation
Pisze testy Playwright gotowe na produkcję w TypeScript: Page Object Model, fixture'y, auto-waiting, lokatory zorientowane na użytkownika, równoległość, CI i sharding, z listą zakazów dla agentów AI. - 100playwright-e2e-testing
Pisze, poprawia i przegląda testy E2E w Playwright dla aplikacji Next.js, w tym lokatory, logowanie i testy niestabilne. - 100playwright
Opisuje framework Playwright do testów E2E: automatyzację przeglądarki, asercje i generowanie testów, w tym lokatory, testy międzyprzeglądarkowe i regresję wizualną.