[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CA1AXS3KMBSMKEGWW7MHDB":3,"skill-same:01M7CA1AXS3KMBSMKEGWW7MHDB":53},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":31,"commitSha":32,"skillDirectory":33,"forksCount":34,"repositoryHtmlUrl":35,"repositoryHomepageUrl":6,"ownerHtmlUrl":36,"ownerBlogUrl":6,"ownerDescription":37,"updatedAt":38,"install":39,"resources":52},"01M7CA1AXS3KMBSMKEGWW7MHDB","e2e-testing",null,"End-to-end testing patterns with Playwright for full-stack Python\u002FReact applications. Use when writing E2E tests for complete user workflows (login, CRUD, navigation), critical path regression tests, or cross-browser validation. Covers test structure, page object model, selector strategy (data-testid > role > label), wait strategies, auth state reuse, test data management, and CI integration. Does NOT cover unit tests or component tests (use pytest-patterns or react-testing-patterns).","om-scogo\u002Fskillsh-scraper","om-scogo","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F160466840?v=4","01M79AWB6DFVCQ7RK70CS34B96","Om Achrekar","01M79AWB6ZM9SKR8KDH1WSSM22",0,"MIT","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fhieutrtr-ai1-skills\u002Fe2e-testing\u002Fskills\u002Fe2e-testing\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: e2e-testing\ndescription: >-\n  End-to-end testing patterns with Playwright for full-stack Python\u002FReact applications.\n  Use when writing E2E tests for complete user workflows (login, CRUD, navigation),\n  critical path regression tests, or cross-browser validation. Covers test structure,\n  page object model, selector strategy (data-testid > role > label), wait strategies,\n  auth state reuse, test data management, and CI integration. Does NOT cover unit tests\n  or component tests (use pytest-patterns or react-testing-patterns).\nlicense: MIT\ncompatibility: 'Playwright 1.40+, Node.js 20+'\nmetadata:\n  author: platform-team\n  version: '1.0.0'\n  sdlc-phase: testing\nallowed-tools: Read Edit Write Bash(npx:*) Bash(npm:*)\ncontext: fork\n---\n\n# E2E Testing\n\n## When to Use\n\nActivate this skill when:\n- Writing E2E tests for complete user workflows (login, CRUD operations, multi-page flows)\n- Creating critical path regression tests that validate the full stack\n- Testing cross-browser compatibility (Chromium, Firefox, WebKit)\n- Validating authentication flows end-to-end\n- Testing file upload\u002Fdownload workflows\n- Writing smoke tests for deployment verification\n\nDo NOT use this skill for:\n- React component unit tests (use `react-testing-patterns`)\n- Python backend unit\u002Fintegration tests (use `pytest-patterns`)\n- TDD workflow enforcement (use `tdd-workflow`)\n- API contract testing without a browser (use `pytest-patterns` with httpx)\n\n## Instructions\n\n### Test Structure\n\n```\ne2e\u002F\n├── playwright.config.ts         # Global Playwright configuration\n├── fixtures\u002F\n│   ├── auth.fixture.ts          # Authentication state setup\n│   └── test-data.fixture.ts     # Test data creation\u002Fcleanup\n├── pages\u002F\n│   ├── base.page.ts             # Base page object with shared methods\n│   ├── login.page.ts            # Login page object\n│   ├── users.page.ts            # Users list page object\n│   └── user-detail.page.ts     # User detail page object\n├── tests\u002F\n│   ├── auth\u002F\n│   │   ├── login.spec.ts\n│   │   └── logout.spec.ts\n│   ├── users\u002F\n│   │   ├── create-user.spec.ts\n│   │   ├── edit-user.spec.ts\n│   │   └── list-users.spec.ts\n│   └── smoke\u002F\n│       └── critical-paths.spec.ts\n└── utils\u002F\n    ├── api-helpers.ts           # Direct API calls for test setup\n    └── test-constants.ts        # Shared constants\n```\n\n**Naming conventions:**\n- Test files: `\u003Cfeature>.spec.ts`\n- Page objects: `\u003Cpage-name>.page.ts`\n- Fixtures: `\u003Cconcern>.fixture.ts`\n- Test names: human-readable sentences describing the user action and expected outcome\n\n### Page Object Model\n\nEvery page gets a page object class that encapsulates selectors and actions. Tests never interact with selectors directly.\n\n**Base page object:**\n```typescript\n\u002F\u002F e2e\u002Fpages\u002Fbase.page.ts\nimport { type Page, type Locator } from \"@playwright\u002Ftest\";\n\nexport abstract class BasePage {\n  constructor(protected readonly page: Page) {}\n\n  \u002F** Navigate to the page's URL. *\u002F\n  abstract goto(): Promise\u003Cvoid>;\n\n  \u002F** Wait for the page to be fully loaded. *\u002F\n  async waitForLoad(): Promise\u003Cvoid> {\n    await this.page.waitForLoadState(\"networkidle\");\n  }\n\n  \u002F** Get a toast\u002Fnotification message. *\u002F\n  get toast(): Locator {\n    return this.page.getByRole(\"alert\");\n  }\n\n  \u002F** Get the page heading. *\u002F\n  get heading(): Locator {\n    return this.page.getByRole(\"heading\", { level: 1 });\n  }\n}\n```\n\n**Concrete page object:**\n```typescript\n\u002F\u002F e2e\u002Fpages\u002Fusers.page.ts\nimport { type Page, type Locator } from \"@playwright\u002Ftest\";\nimport { BasePage } from \".\u002Fbase.page\";\n\nexport class UsersPage extends BasePage {\n  \u002F\u002F ─── Locators ─────────────────────────────────────────\n  readonly createButton: Locator;\n  readonly searchInput: Locator;\n  readonly userTable: Locator;\n\n  constructor(page: Page) {\n    super(page);\n    this.createButton = page.getByTestId(\"create-user-btn\");\n    this.searchInput = page.getByRole(\"searchbox\", { name: \u002Fsearch users\u002Fi });\n    this.userTable = page.getByRole(\"table\");\n  }\n\n  \u002F\u002F ─── Actions ──────────────────────────────────────────\n  async goto(): Promise\u003Cvoid> {\n    await this.page.goto(\"\u002Fusers\");\n    await this.waitForLoad();\n  }\n\n  async searchFor(query: string): Promise\u003Cvoid> {\n    await this.searchInput.fill(query);\n    \u002F\u002F Wait for search results to update (debounced)\n    await this.page.waitForResponse(\"**\u002Fapi\u002Fv1\u002Fusers?*\");\n  }\n\n  async clickCreateUser(): Promise\u003Cvoid> {\n    await this.createButton.click();\n  }\n\n  async getUserRow(email: string): Promise\u003CLocator> {\n    return this.userTable.getByRole(\"row\").filter({ hasText: email });\n  }\n\n  async getUserCount(): Promise\u003Cnumber> {\n    \u002F\u002F Subtract 1 for header row\n    return (await this.userTable.getByRole(\"row\").count()) - 1;\n  }\n}\n```\n\n**Rules for page objects:**\n- One page object per page or major UI section\n- Locators are public readonly properties\n- Actions are async methods\n- Page objects never contain assertions -- tests assert\n- Page objects handle waits internally after actions\n\n### Selector Strategy\n\n**Priority order (highest to lowest):**\n\n| Priority | Selector | Example | When to Use |\n|----------|----------|---------|-------------|\n| 1 | `data-testid` | `getByTestId(\"submit-btn\")` | Interactive elements, dynamic content |\n| 2 | Role | `getByRole(\"button\", { name: \u002Fsave\u002Fi })` | Buttons, links, headings, inputs |\n| 3 | Label | `getByLabel(\"Email\")` | Form inputs with labels |\n| 4 | Placeholder | `getByPlaceholder(\"Search...\")` | Search inputs |\n| 5 | Text | `getByText(\"Welcome back\")` | Static text content |\n\n**NEVER use:**\n- CSS selectors (`.class-name`, `#id`) -- brittle, break on styling changes\n- XPath (`\u002F\u002Fdiv[@class=\"foo\"]`) -- unreadable, extremely brittle\n- DOM structure selectors (`div > span:nth-child(2)`) -- break on layout changes\n\n**Adding data-testid attributes:**\n```tsx\n\u002F\u002F In React components -- add data-testid to interactive elements\n\u003Cbutton data-testid=\"create-user-btn\" onClick={handleCreate}>\n  Create User\n\u003C\u002Fbutton>\n\n\u002F\u002F Convention: kebab-case, descriptive\n\u002F\u002F Pattern: \u003Caction>-\u003Centity>-\u003Celement-type>\n\u002F\u002F Examples: create-user-btn, user-email-input, delete-confirm-dialog\n```\n\n### Wait Strategies\n\n**NEVER use hardcoded waits:**\n```typescript\n\u002F\u002F BAD: Hardcoded wait -- flaky, slow\nawait page.waitForTimeout(3000);\n\n\u002F\u002F BAD: Sleep\nawait new Promise((resolve) => setTimeout(resolve, 2000));\n```\n\n**Use explicit wait conditions:**\n```typescript\n\u002F\u002F GOOD: Wait for a specific element to appear\nawait page.getByRole(\"heading\", { name: \"Dashboard\" }).waitFor();\n\n\u002F\u002F GOOD: Wait for navigation\nawait page.waitForURL(\"\u002Fdashboard\");\n\n\u002F\u002F GOOD: Wait for API response\nawait page.waitForResponse(\n  (response) =>\n    response.url().includes(\"\u002Fapi\u002Fv1\u002Fusers\") && response.status() === 200,\n);\n\n\u002F\u002F GOOD: Wait for network to settle\nawait page.waitForLoadState(\"networkidle\");\n\n\u002F\u002F GOOD: Wait for element state\nawait page.getByTestId(\"submit-btn\").waitFor({ state: \"visible\" });\nawait page.getByTestId(\"loading-spinner\").waitFor({ state: \"hidden\" });\n```\n\n**Auto-waiting:** Playwright auto-waits for elements to be actionable before clicking, filling, etc. Explicit waits are needed only for assertions or complex state transitions.\n\n### Auth State Reuse\n\nAvoid logging in before every test. Save auth state and reuse it.\n\n**Setup auth state once:**\n```typescript\n\u002F\u002F e2e\u002Ffixtures\u002Fauth.fixture.ts\nimport { test as base } from \"@playwright\u002Ftest\";\nimport path from \"path\";\n\nconst AUTH_STATE_PATH = path.resolve(\"e2e\u002F.auth\u002Fuser.json\");\n\nexport const setup = base.extend({});\n\nsetup(\"authenticate\", async ({ page }) => {\n  \u002F\u002F Perform real login\n  await page.goto(\"\u002Flogin\");\n  await page.getByLabel(\"Email\").fill(\"testuser@example.com\");\n  await page.getByLabel(\"Password\").fill(\"TestPassword123!\");\n  await page.getByRole(\"button\", { name: \u002Fsign in\u002Fi }).click();\n\n  \u002F\u002F Wait for auth to complete\n  await page.waitForURL(\"\u002Fdashboard\");\n\n  \u002F\u002F Save signed-in state\n  await page.context().storageState({ path: AUTH_STATE_PATH });\n});\n```\n\n**Reuse in tests:**\n```typescript\n\u002F\u002F playwright.config.ts\nexport default defineConfig({\n  projects: [\n    \u002F\u002F Setup project runs first and saves auth state\n    { name: \"setup\", testDir: \".\u002Fe2e\u002Ffixtures\", testMatch: \"auth.fixture.ts\" },\n    {\n      name: \"chromium\",\n      use: {\n        storageState: \"e2e\u002F.auth\u002Fuser.json\",  \u002F\u002F Reuse auth state\n      },\n      dependencies: [\"setup\"],\n    },\n  ],\n});\n```\n\n### Test Data Management\n\n**Principles:**\n- Tests create their own data (never depend on pre-existing data)\n- Tests clean up after themselves (or use API to reset)\n- Use API calls for setup, not UI interactions (faster, more reliable)\n\n**API helpers for test data:**\n```typescript\n\u002F\u002F e2e\u002Futils\u002Fapi-helpers.ts\nimport { type APIRequestContext } from \"@playwright\u002Ftest\";\n\nexport class TestDataAPI {\n  constructor(private request: APIRequestContext) {}\n\n  async createUser(data: { email: string; displayName: string }) {\n    const response = await this.request.post(\"\u002Fapi\u002Fv1\u002Fusers\", { data });\n    return response.json();\n  }\n\n  async deleteUser(userId: number) {\n    await this.request.delete(`\u002Fapi\u002Fv1\u002Fusers\u002F${userId}`);\n  }\n\n  async createOrder(userId: number, items: Array\u003CRecord\u003Cstring, unknown>>) {\n    const response = await this.request.post(\"\u002Fapi\u002Fv1\u002Forders\", {\n      data: { user_id: userId, items },\n    });\n    return response.json();\n  }\n}\n```\n\n**Usage in tests:**\n```typescript\ntest(\"edit user name\", async ({ page, request }) => {\n  const api = new TestDataAPI(request);\n\n  \u002F\u002F Setup: create user via API (fast)\n  const user = await api.createUser({\n    email: \"edit-test@example.com\",\n    displayName: \"Before Edit\",\n  });\n\n  try {\n    \u002F\u002F Test: edit via UI\n    const usersPage = new UsersPage(page);\n    await usersPage.goto();\n    \u002F\u002F ... perform edit via UI ...\n  } finally {\n    \u002F\u002F Cleanup: remove test data\n    await api.deleteUser(user.id);\n  }\n});\n```\n\n### Debugging Flaky Tests\n\n**1. Use trace viewer for failures:**\n```typescript\n\u002F\u002F playwright.config.ts\nuse: {\n  trace: \"on-first-retry\",  \u002F\u002F Capture trace only on retry\n}\n```\n\nView trace: `npx playwright show-trace trace.zip`\n\n**2. Run in headed mode for debugging:**\n```bash\nnpx playwright test --headed --debug tests\u002Fusers\u002Fcreate-user.spec.ts\n```\n\n**3. Common causes of flaky tests:**\n| Cause | Fix |\n|-------|-----|\n| Hardcoded waits | Use explicit wait conditions |\n| Shared test data | Each test creates its own data |\n| Animation interference | Set `animations: \"disabled\"` in config |\n| Race conditions | Wait for API responses before assertions |\n| Viewport-dependent behavior | Set explicit viewport in config |\n| Session leaks between tests | Use `storageState` correctly, clear cookies |\n\n**4. Retry strategy:**\n```typescript\n\u002F\u002F playwright.config.ts\nexport default defineConfig({\n  retries: process.env.CI ? 2 : 0,  \u002F\u002F Retry in CI only\n});\n```\n\n### CI Configuration\n\n```yaml\n# .github\u002Fworkflows\u002Fe2e.yml\nname: E2E Tests\non:\n  push:\n    branches: [main]\n  pull_request:\n    branches: [main]\n\njobs:\n  e2e:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\u002Fcheckout@v4\n      - uses: actions\u002Fsetup-node@v4\n        with:\n          node-version: 20\n          cache: npm\n\n      - name: Install dependencies\n        run: npm ci\n\n      - name: Install Playwright browsers\n        run: npx playwright install --with-deps chromium\n\n      - name: Start application\n        run: |\n          docker compose up -d\n          npx wait-on http:\u002F\u002Flocalhost:3000 --timeout 60000\n\n      - name: Run E2E tests\n        run: npx playwright test\n\n      - name: Upload test report\n        if: always()\n        uses: actions\u002Fupload-artifact@v4\n        with:\n          name: playwright-report\n          path: playwright-report\u002F\n          retention-days: 14\n\n      - name: Upload traces on failure\n        if: failure()\n        uses: actions\u002Fupload-artifact@v4\n        with:\n          name: test-traces\n          path: test-results\u002F\n```\n\nUse `scripts\u002Frun-e2e-with-report.sh` to run Playwright with HTML report output locally.\n\n## Examples\n\nSee `references\u002Fpage-object-template.ts` for annotated page object class.\nSee `references\u002Fe2e-test-template.ts` for annotated E2E test.\nSee `references\u002Fplaywright-config-example.ts` for production Playwright config.\n","# E2E Testing\n\n## When to Use\n\nActivate this skill when:\n- Writing E2E tests for complete user workflows (login, CRUD operations, multi-page flows)\n- Creating critical path regression tests that validate the full stack\n- Testing cross-browser compatibility (Chromium, Firefox, WebKit)\n- Validating authentication flows end-to-end\n- Testing file upload\u002Fdownload workflows\n- Writing smoke tests for deployment verification\n\nDo NOT use this skill for:\n- React component unit tests (use `react-testing-patterns`)\n- Python backend unit\u002Fintegration tests (use `pytest-patterns`)\n- TDD workflow enforcement (use `tdd-workflow`)\n- API contract testing without a browser (use `pytest-patterns` with httpx)\n\n## Instructions\n\n### Test Structure\n\n```\ne2e\u002F\n├── playwright.config.ts         # Global Playwright configuration\n├── fixtures\u002F\n│   ├── auth.fixture.ts          # Authentication state setup\n│   └── test-data.fixture.ts     # Test data creation\u002Fcleanup\n├── pages\u002F\n│   ├── base.page.ts             # Base page object with shared methods\n│   ├── login.page.ts            # Login page object\n│   ├── users.page.ts            # Users list page object\n│   └── user-detail.page.ts     # User detail page object\n├── tests\u002F\n│   ├── auth\u002F\n│   │   ├── login.spec.ts\n│   │   └── logout.spec.ts\n│   ├── users\u002F\n│   │   ├── create-user.spec.ts\n│   │   ├── edit-user.spec.ts\n│   │   └── list-users.spec.ts\n│   └── smoke\u002F\n│       └── critical-paths.spec.ts\n└── utils\u002F\n    ├── api-helpers.ts           # Direct API calls for test setup\n    └── test-constants.ts        # Shared constants\n```\n\n**Naming conventions:**\n- Test files: `\u003Cfeature>.spec.ts`\n- Page objects: `\u003Cpage-name>.page.ts`\n- Fixtures: `\u003Cconcern>.fixture.ts`\n- Test names: human-readable sentences describing the user action and expected outcome\n\n### Page Object Model\n\nEvery page gets a page object class that encapsulates selectors and actions. Tests never interact with selectors directly.\n\n**Base page object:**\n```typescript\n\u002F\u002F e2e\u002Fpages\u002Fbase.page.ts\nimport { type Page, type Locator } from \"@playwright\u002Ftest\";\n\nexport abstract class BasePage {\n  constructor(protected readonly page: Page) {}\n\n  \u002F** Navigate to the page's URL. *\u002F\n  abstract goto(): Promise\u003Cvoid>;\n\n  \u002F** Wait for the page to be fully loaded. *\u002F\n  async waitForLoad(): Promise\u003Cvoid> {\n    await this.page.waitForLoadState(\"networkidle\");\n  }\n\n  \u002F** Get a toast\u002Fnotification message. *\u002F\n  get toast(): Locator {\n    return this.page.getByRole(\"alert\");\n  }\n\n  \u002F** Get the page heading. *\u002F\n  get heading(): Locator {\n    return this.page.getByRole(\"heading\", { level: 1 });\n  }\n}\n```\n\n**Concrete page object:**\n```typescript\n\u002F\u002F e2e\u002Fpages\u002Fusers.page.ts\nimport { type Page, type Locator } from \"@playwright\u002Ftest\";\nimport { BasePage } from \".\u002Fbase.page\";\n\nexport class UsersPage extends BasePage {\n  \u002F\u002F ─── Locators ─────────────────────────────────────────\n  readonly createButton: Locator;\n  readonly searchInput: Locator;\n  readonly userTable: Locator;\n\n  constructor(page: Page) {\n    super(page);\n    this.createButton = page.getByTestId(\"create-user-btn\");\n    this.searchInput = page.getByRole(\"searchbox\", { name: \u002Fsearch users\u002Fi });\n    this.userTable = page.getByRole(\"table\");\n  }\n\n  \u002F\u002F ─── Actions ──────────────────────────────────────────\n  async goto(): Promise\u003Cvoid> {\n    await this.page.goto(\"\u002Fusers\");\n    await this.waitForLoad();\n  }\n\n  async searchFor(query: string): Promise\u003Cvoid> {\n    await this.searchInput.fill(query);\n    \u002F\u002F Wait for search results to update (debounced)\n    await this.page.waitForResponse(\"**\u002Fapi\u002Fv1\u002Fusers?*\");\n  }\n\n  async clickCreateUser(): Promise\u003Cvoid> {\n    await this.createButton.click();\n  }\n\n  async getUserRow(email: string): Promise\u003CLocator> {\n    return this.userTable.getByRole(\"row\").filter({ hasText: email });\n  }\n\n  async getUserCount(): Promise\u003Cnumber> {\n    \u002F\u002F Subtract 1 for header row\n    return (await this.userTable.getByRole(\"row\").count()) - 1;\n  }\n}\n```\n\n**Rules for page objects:**\n- One page object per page or major UI section\n- Locators are public readonly properties\n- Actions are async methods\n- Page objects never contain assertions -- tests assert\n- Page objects handle waits internally after actions\n\n### Selector Strategy\n\n**Priority order (highest to lowest):**\n\n| Priority | Selector | Example | When to Use |\n|----------|----------|---------|-------------|\n| 1 | `data-testid` | `getByTestId(\"submit-btn\")` | Interactive elements, dynamic content |\n| 2 | Role | `getByRole(\"button\", { name: \u002Fsave\u002Fi })` | Buttons, links, headings, inputs |\n| 3 | Label | `getByLabel(\"Email\")` | Form inputs with labels |\n| 4 | Placeholder | `getByPlaceholder(\"Search...\")` | Search inputs |\n| 5 | Text | `getByText(\"Welcome back\")` | Static text content |\n\n**NEVER use:**\n- CSS selectors (`.class-name`, `#id`) -- brittle, break on styling changes\n- XPath (`\u002F\u002Fdiv[@class=\"foo\"]`) -- unreadable, extremely brittle\n- DOM structure selectors (`div > span:nth-child(2)`) -- break on layout changes\n\n**Adding data-testid attributes:**\n```tsx\n\u002F\u002F In React components -- add data-testid to interactive elements\n\u003Cbutton data-testid=\"create-user-btn\" onClick={handleCreate}>\n  Create User\n\u003C\u002Fbutton>\n\n\u002F\u002F Convention: kebab-case, descriptive\n\u002F\u002F Pattern: \u003Caction>-\u003Centity>-\u003Celement-type>\n\u002F\u002F Examples: create-user-btn, user-email-input, delete-confirm-dialog\n```\n\n### Wait Strategies\n\n**NEVER use hardcoded waits:**\n```typescript\n\u002F\u002F BAD: Hardcoded wait -- flaky, slow\nawait page.waitForTimeout(3000);\n\n\u002F\u002F BAD: Sleep\nawait new Promise((resolve) => setTimeout(resolve, 2000));\n```\n\n**Use explicit wait conditions:**\n```typescript\n\u002F\u002F GOOD: Wait for a specific element to appear\nawait page.getByRole(\"heading\", { name: \"Dashboard\" }).waitFor();\n\n\u002F\u002F GOOD: Wait for navigation\nawait page.waitForURL(\"\u002Fdashboard\");\n\n\u002F\u002F GOOD: Wait for API response\nawait page.waitForResponse(\n  (response) =>\n    response.url().includes(\"\u002Fapi\u002Fv1\u002Fusers\") && response.status() === 200,\n);\n\n\u002F\u002F GOOD: Wait for network to settle\nawait page.waitForLoadState(\"networkidle\");\n\n\u002F\u002F GOOD: Wait for element state\nawait page.getByTestId(\"submit-btn\").waitFor({ state: \"visible\" });\nawait page.getByTestId(\"loading-spinner\").waitFor({ state: \"hidden\" });\n```\n\n**Auto-waiting:** Playwright auto-waits for elements to be actionable before clicking, filling, etc. Explicit waits are needed only for assertions or complex state transitions.\n\n### Auth State Reuse\n\nAvoid logging in before every test. Save auth state and reuse it.\n\n**Setup auth state once:**\n```typescript\n\u002F\u002F e2e\u002Ffixtures\u002Fauth.fixture.ts\nimport { test as base } from \"@playwright\u002Ftest\";\nimport path from \"path\";\n\nconst AUTH_STATE_PATH = path.resolve(\"e2e\u002F.auth\u002Fuser.json\");\n\nexport const setup = base.extend({});\n\nsetup(\"authenticate\", async ({ page }) => {\n  \u002F\u002F Perform real login\n  await page.goto(\"\u002Flogin\");\n  await page.getByLabel(\"Email\").fill(\"testuser@example.com\");\n  await page.getByLabel(\"Password\").fill(\"TestPassword123!\");\n  await page.getByRole(\"button\", { name: \u002Fsign in\u002Fi }).click();\n\n  \u002F\u002F Wait for auth to complete\n  await page.waitForURL(\"\u002Fdashboard\");\n\n  \u002F\u002F Save signed-in state\n  await page.context().storageState({ path: AUTH_STATE_PATH });\n});\n```\n\n**Reuse in tests:**\n```typescript\n\u002F\u002F playwright.config.ts\nexport default defineConfig({\n  projects: [\n    \u002F\u002F Setup project runs first and saves auth state\n    { name: \"setup\", testDir: \".\u002Fe2e\u002Ffixtures\", testMatch: \"auth.fixture.ts\" },\n    {\n      name: \"chromium\",\n      use: {\n        storageState: \"e2e\u002F.auth\u002Fuser.json\",  \u002F\u002F Reuse auth state\n      },\n      dependencies: [\"setup\"],\n    },\n  ],\n});\n```\n\n### Test Data Management\n\n**Principles:**\n- Tests create their own data (never depend on pre-existing data)\n- Tests clean up after themselves (or use API to reset)\n- Use API calls for setup, not UI interactions (faster, more reliable)\n\n**API helpers for test data:**\n```typescript\n\u002F\u002F e2e\u002Futils\u002Fapi-helpers.ts\nimport { type APIRequestContext } from \"@playwright\u002Ftest\";\n\nexport class TestDataAPI {\n  constructor(private request: APIRequestContext) {}\n\n  async createUser(data: { email: string; displayName: string }) {\n    const response = await this.request.post(\"\u002Fapi\u002Fv1\u002Fusers\", { data });\n    return response.json();\n  }\n\n  async deleteUser(userId: number) {\n    await this.request.delete(`\u002Fapi\u002Fv1\u002Fusers\u002F${userId}`);\n  }\n\n  async createOrder(userId: number, items: Array\u003CRecord\u003Cstring, unknown>>) {\n    const response = await this.request.post(\"\u002Fapi\u002Fv1\u002Forders\", {\n      data: { user_id: userId, items },\n    });\n    return response.json();\n  }\n}\n```\n\n**Usage in tests:**\n```typescript\ntest(\"edit user name\", async ({ page, request }) => {\n  const api = new TestDataAPI(request);\n\n  \u002F\u002F Setup: create user via API (fast)\n  const user = await api.createUser({\n    email: \"edit-test@example.com\",\n    displayName: \"Before Edit\",\n  });\n\n  try {\n    \u002F\u002F Test: edit via UI\n    const usersPage = new UsersPage(page);\n    await usersPage.goto();\n    \u002F\u002F ... perform edit via UI ...\n  } finally {\n    \u002F\u002F Cleanup: remove test data\n    await api.deleteUser(user.id);\n  }\n});\n```\n\n### Debugging Flaky Tests\n\n**1. Use trace viewer for failures:**\n```typescript\n\u002F\u002F playwright.config.ts\nuse: {\n  trace: \"on-first-retry\",  \u002F\u002F Capture trace only on retry\n}\n```\n\nView trace: `npx playwright show-trace trace.zip`\n\n**2. Run in headed mode for debugging:**\n```bash\nnpx playwright test --headed --debug tests\u002Fusers\u002Fcreate-user.spec.ts\n```\n\n**3. Common causes of flaky tests:**\n| Cause | Fix |\n|-------|-----|\n| Hardcoded waits | Use explicit wait conditions |\n| Shared test data | Each test creates its own data |\n| Animation interference | Set `animations: \"disabled\"` in config |\n| Race conditions | Wait for API responses before assertions |\n| Viewport-dependent behavior | Set explicit viewport in config |\n| Session leaks between tests | Use `storageState` correctly, clear cookies |\n\n**4. Retry strategy:**\n```typescript\n\u002F\u002F playwright.config.ts\nexport default defineConfig({\n  retries: process.env.CI ? 2 : 0,  \u002F\u002F Retry in CI only\n});\n```\n\n### CI Configuration\n\n```yaml\n# .github\u002Fworkflows\u002Fe2e.yml\nname: E2E Tests\non:\n  push:\n    branches: [main]\n  pull_request:\n    branches: [main]\n\njobs:\n  e2e:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\u002Fcheckout@v4\n      - uses: actions\u002Fsetup-node@v4\n        with:\n          node-version: 20\n          cache: npm\n\n      - name: Install dependencies\n        run: npm ci\n\n      - name: Install Playwright browsers\n        run: npx playwright install --with-deps chromium\n\n      - name: Start application\n        run: |\n          docker compose up -d\n          npx wait-on http:\u002F\u002Flocalhost:3000 --timeout 60000\n\n      - name: Run E2E tests\n        run: npx playwright test\n\n      - name: Upload test report\n        if: always()\n        uses: actions\u002Fupload-artifact@v4\n        with:\n          name: playwright-report\n          path: playwright-report\u002F\n          retention-days: 14\n\n      - name: Upload traces on failure\n        if: failure()\n        uses: actions\u002Fupload-artifact@v4\n        with:\n          name: test-traces\n          path: test-results\u002F\n```\n\nUse `scripts\u002Frun-e2e-with-report.sh` to run Playwright with HTML report output locally.\n\n## Examples\n\nSee `references\u002Fpage-object-template.ts` for annotated page object class.\nSee `references\u002Fe2e-test-template.ts` for annotated E2E test.\nSee `references\u002Fplaywright-config-example.ts` for production Playwright config.\n",{"name":5,"context":24,"license":15,"metadata":25,"description":7,"allowed-tools":29,"compatibility":30},"fork",{"author":26,"version":27,"sdlc-phase":28},"platform-team","1.0.0","testing","Read Edit Write Bash(npx:*) Bash(npm:*)","Playwright 1.40+, Node.js 20+","main","8859218955d9504cd18b59e7892100718039d3b4","data\u002Fskills\u002Fhieutrtr-ai1-skills\u002Fe2e-testing\u002Fskills\u002Fe2e-testing",1,"https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper","https:\u002F\u002Fgithub.com\u002Fom-scogo","SDE-1 @ Scogo ","2026-07-18 12:22:46",{"source":8,"skillName":5,"commands":40,"prompt":50,"zipAvailable":51},[41,44,47],{"tool":42,"command":43},"npx","npx skills add om-scogo\u002Fskillsh-scraper --skill e2e-testing",{"tool":45,"command":46},"bunx","bunx skills add om-scogo\u002Fskillsh-scraper --skill e2e-testing",{"tool":48,"command":49},"pnpm","pnpm dlx skills add om-scogo\u002Fskillsh-scraper --skill e2e-testing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fhieutrtr-ai1-skills\u002Fe2e-testing\u002Fskills\u002Fe2e-testing\u002FSKILL.md",true,[],[54,61,66,73,78,85],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":19},"01M7D6MC9FAAEV4CMNYX8W7JTG","arxiv-search","Search arXiv physics, math, and computer science preprints using natural language queries. Powered by Valyu semantic search.","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fyorkeccak-scientific-skills\u002Farxiv-search\u002Fskills\u002Farxiv-search\u002FSKILL.md",[],[],{"skillNo":62,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M7D6M85CKKN87TA98VCQV4H7","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fyorkeccak-scientific-skills\u002Farxiv-search\u002FSkill.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M7D4ZTCS4DR3CE4JY06X84T2","working-with-legacy-code","Safely change and test untested codebases using Feathers' \"Working Effectively with Legacy Code\". Use when the user mentions \"legacy code\", \"no tests\", \"untested codebase\", \"how do I test this\", \"seams\", \"characterization tests\", \"golden master\", \"sprout method\", \"afraid to change this code\", \"monster method\", \"dependency breaking\", or \"inherited a messy codebase\". Also trigger when changing code without tests safely, getting a class under test when constructors, statics, or singletons block it, adding features to tangled modules, or planning incremental test coverage for an old codebase. Covers the legacy-code change algorithm, seams, characterization tests, sprout\u002Fwrap, and dependency-breaking techniques. For refactoring code that already has tests, see refactoring-patterns. For day-to-day code quality, see clean-code.","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fworking-with-legacy-code\u002Fworking-with-legacy-code\u002FSKILL.md",[],[],{"skillNo":74,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7D4ZHZKJD2RSNGAF63V14P4","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fworking-with-legacy-code\u002FSkill.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7D4ZB4CJBFW5JE67CPH2QRV","web-typography","Select, pair, and implement typefaces for web projects. Use when the user mentions \"font pairing\", \"which typeface\", \"line height\", \"responsive typography\", \"web font loading\", \"type hierarchy\", \"variable fonts\", \"FOUT\u002FFOIT\", \"typographic scale\", or \"the text is hard to read\". Also trigger when choosing between system fonts and web fonts, optimizing font-loading performance, or designing readable long-form content. Covers readability evaluation, CSS implementation, and performance optimization. For overall UI design systems, see refactoring-ui. For dramatic typographic experiences, see top-design.","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fweb-typography\u002Fweb-typography\u002FSKILL.md",[],[],{"skillNo":86,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7D4Z4MVYVY3NMJ18BNV6WNA","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fweb-typography\u002FSkill.md",[],[]]