Przejdź do treści
Biblioteka skilli
Programowanie · Testowanie

qa-e2e-playwright

/qa-e2e-playwright

Pisze i porządkuje zestawy testów Playwright w TypeScript: konfigurację, lokatory, uwierzytelnianie, mocki i sharding w CI.

Repozytorium
agent-skills ↗
Licencja
MIT
Ostatnia zmiana repozytorium
10.11.2026

Ocena i bezpieczeństwo

95/ 100Klasa: dobry
Format20 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
2
Przestarzałość

Brak sygnałów. Repozytorium zmienione 10.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Pisze i porządkuje zestawy testów Playwright w TypeScript: konfigurację, lokatory, uwierzytelnianie, mocki i sharding w CI.

Wyzwalacze z opisu

playwrightplaywright testplaywright configlocatorsstorageStatetrace viewerplaywright codegenplaywright sharding
Oryginalny opis (EN)

Use this skill when the user says 'playwright', 'playwright test', 'playwright config', 'locators', 'storageState', 'trace viewer', 'playwright codegen', 'playwright sharding', 'playwright fixtures'. It writes and structures Playwright Test suites in TypeScript: config, resilient locators, web-first assertions, authentication reuse, fixtures/page objects, network mocking, tracing and CI sharding. Do NOT use for: choosing between E2E tools or overall E2E strategy (use quality-e2e-testing or e2e-testing), visual regression (use quality/visual-testing), unit tests (use quality/unit-testing).

Jak działa

  1. Purpose
  2. Agent Protocol
  3. Key Concepts
  4. Config
  5. Authentication Once, Reused
  6. Locator Priority
  7. Test with Fixture and Mocked Dependency
  8. Test Data
  9. Debugging
  10. CI Sharding
Sekcje z nagłówków SKILL.md, w oryginale · 156 linii, 748 słów
Podgląd SKILL.md
---
name: qa-e2e-playwright
description: >
  Use this skill when the user says 'playwright', 'playwright test', 'playwright config', 'locators', 'storageState', 'trace viewer', 'playwright codegen', 'playwright sharding', 'playwright fixtures'. It writes and structures Playwright Test suites in TypeScript: config, resilient locators, web-first assertions, authentication reuse, fixtures/page objects, network mocking, tracing and CI sharding. Do NOT use for: choosing between E2E tools or overall E2E strategy (use quality-e2e-testing or e2e-testing), visual regression (use quality/visual-testing), unit tests (use quality/unit-testing).
version: "2.0.0"
author: "j4flmao"
license: "MIT"
tags: [quality-assurance, e2e, playwright, typescript, testing, ci]
---

# E2E Testing with Playwright

## Purpose
Write fast, non-flaky end-to-end tests with Playwright Test: each test runs in an isolated browser context, actions auto-wait for actionability, and assertions retry until a timeout. Structure suites so they stay maintainable and parallelize in CI.

## Agent Protocol

### Trigger
"playwright", "@playwright/test", "playwright.config", "getByRole", "storageState", "trace viewer", "codegen", "shard", "page object".

### Input Context
- App URL/start command, auth method, critical user journeys.
- Browsers to cover, CI provider.

### Output Artifact
`playwright.config.ts`, test files, fixtures; CI job on request.

### Response Format
```
Journeys covered: {list}
Projects: {setup, chromium, firefox, webkit, mobile}
Auth: {setup project + storageState}
Data strategy: {API seeding | mocked routes}
CI: {workers, shards, retries, trace policy}
```

## Key Concepts
- **Browser context**: lightweight, isolated (cookies, storage) — a fresh one per test by default, so tests do not leak state.
- **Auto-waiting**: actions wait for the element to be attached, visible, stable, enabled and receiving events.
- **Web-first assertions**: `await expect(locator).toBeVisible()` retries until the expect timeout (5 s default). Never use `page.waitForTimeout()` for synchronization.

## Config

```typescript
// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  testDir: './e2e',
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 4 : undefined,
  reporter: process.env.CI ? [['html', { open: 'never' }], ['github']] : 'list',
  use: {
    baseURL: process.env.BASE_URL ?? 'http://localhost:3000',
    trace: 'on-first-retry',
    screenshot: 'only-on-failure',
  },
  projects: [
    { name: 'setup', testMatch: /.*\.setup\.ts/ },
    { name: 'chromium', use: { ...devices['Desktop Chrome'], storageState: 'playwright/.auth/user.json' }, dependencies: ['setup'] },
    { name: 'webkit', use: { ...devices['Desktop Safari'], storageState: 'playwright/.auth/user.json' }, dependencies: ['setup'] },
  ],
  webServer: { command: 'npm run start', url: 'http://localhost:3000', reuseExistingServer: !process.env.CI },
});
```

## Authentication Once, Reused

```typescript
// e2e/auth.setup.ts
import { test as setup, expect } from '@playwright/test';

setup('authenticate', async ({ page }) => {
  await page.goto('/login');
  await page.getByLabel('Email').fill(process.env.E2E_USER!);
  await page.getByLabel('Password').fill(process.env.E2E_PASSWORD!);
  await page.getByRole('button', { name: 'Sign in' }).click();
  await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
  await page.context().storageState({ path: 'playwright/.auth/user.json' });
});
```
Add `playwright/.auth` to `.gitignore`; use dedicated test accounts from CI secrets.

## Locator Priority
1. `getByRole('button', { name: 'Checkout' })` — mirrors accessibility tree
2. `getByLabel`, `getByPlaceholder`, `getByText`
3. `getByTestId('cart-total')` (`data-testid`) for elements without accessible names
4. CSS/XPath — last resort; brittle

## Test with Fixture and Mocked Dependency

```typescript
import { test as base, expect } from '@playwright/test';

class CartPage {
  constructor(private readonly page: import('@playwright/test').Page) {}
  async open() { await this.page.goto('/cart'); }
  total() { return this.page.getByTestId('cart-total'); }
  checkout() { return this.page.getByRole('button', { name: 'Checkout' }); }
}

const test = base.extend<{ cart: CartPage }>({
  cart: async ({ page }, use) => { await use(new CartPage(page)); },
});

test('shows shipping estimate from API', async ({ page, cart }) => {
  await page.route('**/api/shipping-estimate', (route) =>
    route.fulfill({ json: { amount: 4.99, currency: 'USD' } }),
  );
  await cart.open();
  await expect(cart.total()).toContainText('$4.99');
  await expect(cart.checkout()).toBeEnabled();
});
```

## Test Data
- Seed via API (`request` fixture) in `beforeEach`/fixtures rather than through the UI.
- Make data unique per test (`test.info().workerIndex`, UUID suffix) so parallel workers do not collide.
- Mock only third parties you do not control; keep at least one journey running against the real backend.

## Debugging
- `npx playwright test --ui` (UI mode), `--debug` (Inspector), `npx playwright codegen <url>`.
- `npx playwright show-trace trace.zip` or the HTML report: DOM snapshots, network, console per step.

## CI Sharding

```yaml
# GitHub Actions matrix
strategy:
  fail-fast: false
  matrix:
    shard: [1/4, 2/4, 3/4, 4/4]
steps:
  - uses: actions/checkout@v4
  - uses: actions/setup-node@v4
    with: { node-version: 22 }
  - run: npm ci
  - run: npx playwright install --with-deps
  - run: npx playwright test --shard=${{ matrix.shard }}
```
Merge shard reports with the `blob` reporter and `npx playwright merge-reports`.

## Anti-Patterns
| Anti-pattern | Fix |
|--------------|-----|
| `waitForTimeout(3000)` | Web-first assertions |
| `expect(await loc.isVisible()).toBe(true)` | `await expect(loc).toBeVisible()` (retries) |
| CSS chains tied to layout | Role/label/test-id locators |
| Logging in through UI in every test | Setup project + `storageState` |
| Tests depending on order | Isolated data per test |
| Retrying to hide flakiness | Inspect traces of retried tests; fix root cause |

## Checklist
- [ ] Critical journeys only (E2E is the top of the pyramid)
- [ ] Auth via setup project
- [ ] No hard waits; web-first assertions
- [ ] Traces on first retry, reports uploaded in CI
- [ ] Sharded/parallel in CI with isolated data

## References
- `skills/quality/quality-e2e-testing/SKILL.md` — E2E strategy and tool selection
- `skills/quality/visual-testing/SKILL.md` — screenshot comparison

Wersje

W bazie nie ma innych skilli o nazwie qa-e2e-playwright.

Migawka bazy z 13.11.2026 · wersja paczki 410f4e8640c9 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 95frontend-playwright-testing
    Pisze stabilne testy end-to-end i komponentowe w Playwright: lokatory ról, asercje, ponowne użycie logowania i konfigurację CI.
  • 100playwright-ops
    Obsługuje testy end-to-end Playwright: selektory, fixture'y, mockowanie sieci, uwierzytelnianie, równoległość, CI, regresję wizualną i polowanie na niestabilne testy.
  • 90e2e-playwright
    Projektuje testy e2e w Playwright: konfigurację równoległą, Page Object Model, lokatory semantyczne, reużycie sesji i wykrywanie niestabilnych testów.
  • 100playwright-e2e-testing
    Pisze, poprawia i przegląda testy E2E w Playwright dla aplikacji Next.js, w tym lokatory, logowanie i testy niestabilne.
  • 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-skill
    Przekazuje aktualne wzorce Playwright 1.64 do pisania, debugowania i skalowania testów: locatory, niestabilne testy, trace.zip, konfiguracja projektów, mockowanie sieci, uwierzytelnianie, testy wizualne i dostępności oraz sharding w CI.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.