@athenaflow/plugin-e2e-test-builder 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +20 -0
- package/.codex-plugin/plugin.json +15 -0
- package/dist/2.0.8/.agents/plugins/marketplace.json +14 -0
- package/dist/2.0.8/claude/plugin/.claude-plugin/plugin.json +20 -0
- package/dist/2.0.8/claude/plugin/package.json +9 -0
- package/dist/2.0.8/claude/plugin/skills/add-e2e-tests/SKILL.md +217 -0
- package/dist/2.0.8/claude/plugin/skills/add-e2e-tests/agents/claude.yaml +1 -0
- package/dist/2.0.8/claude/plugin/skills/add-e2e-tests/agents/openai.yaml +10 -0
- package/dist/2.0.8/claude/plugin/skills/add-e2e-tests/references/authentication.md +8 -0
- package/dist/2.0.8/claude/plugin/skills/add-e2e-tests/references/error-recovery.md +43 -0
- package/dist/2.0.8/claude/plugin/skills/add-e2e-tests/references/scaffolding.md +12 -0
- package/dist/2.0.8/claude/plugin/skills/add-e2e-tests/references/tracker-template.md +53 -0
- package/dist/2.0.8/claude/plugin/skills/analyze-test-codebase/SKILL.md +142 -0
- package/dist/2.0.8/claude/plugin/skills/analyze-test-codebase/agents/claude.yaml +3 -0
- package/dist/2.0.8/claude/plugin/skills/analyze-test-codebase/agents/openai.yaml +4 -0
- package/dist/2.0.8/claude/plugin/skills/fix-flaky-tests/SKILL.md +160 -0
- package/dist/2.0.8/claude/plugin/skills/fix-flaky-tests/agents/claude.yaml +3 -0
- package/dist/2.0.8/claude/plugin/skills/fix-flaky-tests/agents/openai.yaml +10 -0
- package/dist/2.0.8/claude/plugin/skills/fix-flaky-tests/references/fix-patterns.md +91 -0
- package/dist/2.0.8/claude/plugin/skills/generate-test-cases/SKILL.md +184 -0
- package/dist/2.0.8/claude/plugin/skills/generate-test-cases/agents/claude.yaml +3 -0
- package/dist/2.0.8/claude/plugin/skills/generate-test-cases/agents/openai.yaml +10 -0
- package/dist/2.0.8/claude/plugin/skills/generate-test-cases/references/scenario-categories.md +36 -0
- package/dist/2.0.8/claude/plugin/skills/plan-test-coverage/SKILL.md +116 -0
- package/dist/2.0.8/claude/plugin/skills/plan-test-coverage/agents/claude.yaml +3 -0
- package/dist/2.0.8/claude/plugin/skills/plan-test-coverage/agents/openai.yaml +10 -0
- package/dist/2.0.8/claude/plugin/skills/review-test-cases/SKILL.md +147 -0
- package/dist/2.0.8/claude/plugin/skills/review-test-cases/agents/claude.yaml +3 -0
- package/dist/2.0.8/claude/plugin/skills/review-test-cases/agents/openai.yaml +10 -0
- package/dist/2.0.8/claude/plugin/skills/review-test-code/SKILL.md +189 -0
- package/dist/2.0.8/claude/plugin/skills/review-test-code/agents/claude.yaml +3 -0
- package/dist/2.0.8/claude/plugin/skills/review-test-code/agents/openai.yaml +10 -0
- package/dist/2.0.8/claude/plugin/skills/write-test-code/SKILL.md +227 -0
- package/dist/2.0.8/claude/plugin/skills/write-test-code/agents/claude.yaml +3 -0
- package/dist/2.0.8/claude/plugin/skills/write-test-code/agents/openai.yaml +10 -0
- package/dist/2.0.8/claude/plugin/skills/write-test-code/references/anti-patterns.md +88 -0
- package/dist/2.0.8/claude/plugin/skills/write-test-code/references/api-setup-teardown.md +83 -0
- package/dist/2.0.8/claude/plugin/skills/write-test-code/references/auth-patterns.md +63 -0
- package/dist/2.0.8/claude/plugin/skills/write-test-code/references/mapping-tables.md +56 -0
- package/dist/2.0.8/claude/plugin/skills/write-test-code/references/network-interception.md +56 -0
- package/dist/2.0.8/codex/plugin/.codex-plugin/plugin.json +15 -0
- package/dist/2.0.8/codex/plugin/package.json +9 -0
- package/dist/2.0.8/codex/plugin/skills/add-e2e-tests/SKILL.md +217 -0
- package/dist/2.0.8/codex/plugin/skills/add-e2e-tests/agents/claude.yaml +1 -0
- package/dist/2.0.8/codex/plugin/skills/add-e2e-tests/agents/openai.yaml +10 -0
- package/dist/2.0.8/codex/plugin/skills/add-e2e-tests/references/authentication.md +8 -0
- package/dist/2.0.8/codex/plugin/skills/add-e2e-tests/references/error-recovery.md +43 -0
- package/dist/2.0.8/codex/plugin/skills/add-e2e-tests/references/scaffolding.md +12 -0
- package/dist/2.0.8/codex/plugin/skills/add-e2e-tests/references/tracker-template.md +53 -0
- package/dist/2.0.8/codex/plugin/skills/analyze-test-codebase/SKILL.md +142 -0
- package/dist/2.0.8/codex/plugin/skills/analyze-test-codebase/agents/claude.yaml +3 -0
- package/dist/2.0.8/codex/plugin/skills/analyze-test-codebase/agents/openai.yaml +4 -0
- package/dist/2.0.8/codex/plugin/skills/fix-flaky-tests/SKILL.md +160 -0
- package/dist/2.0.8/codex/plugin/skills/fix-flaky-tests/agents/claude.yaml +3 -0
- package/dist/2.0.8/codex/plugin/skills/fix-flaky-tests/agents/openai.yaml +10 -0
- package/dist/2.0.8/codex/plugin/skills/fix-flaky-tests/references/fix-patterns.md +91 -0
- package/dist/2.0.8/codex/plugin/skills/generate-test-cases/SKILL.md +184 -0
- package/dist/2.0.8/codex/plugin/skills/generate-test-cases/agents/claude.yaml +3 -0
- package/dist/2.0.8/codex/plugin/skills/generate-test-cases/agents/openai.yaml +10 -0
- package/dist/2.0.8/codex/plugin/skills/generate-test-cases/references/scenario-categories.md +36 -0
- package/dist/2.0.8/codex/plugin/skills/plan-test-coverage/SKILL.md +116 -0
- package/dist/2.0.8/codex/plugin/skills/plan-test-coverage/agents/claude.yaml +3 -0
- package/dist/2.0.8/codex/plugin/skills/plan-test-coverage/agents/openai.yaml +10 -0
- package/dist/2.0.8/codex/plugin/skills/review-test-cases/SKILL.md +147 -0
- package/dist/2.0.8/codex/plugin/skills/review-test-cases/agents/claude.yaml +3 -0
- package/dist/2.0.8/codex/plugin/skills/review-test-cases/agents/openai.yaml +10 -0
- package/dist/2.0.8/codex/plugin/skills/review-test-code/SKILL.md +189 -0
- package/dist/2.0.8/codex/plugin/skills/review-test-code/agents/claude.yaml +3 -0
- package/dist/2.0.8/codex/plugin/skills/review-test-code/agents/openai.yaml +10 -0
- package/dist/2.0.8/codex/plugin/skills/write-test-code/SKILL.md +227 -0
- package/dist/2.0.8/codex/plugin/skills/write-test-code/agents/claude.yaml +3 -0
- package/dist/2.0.8/codex/plugin/skills/write-test-code/agents/openai.yaml +10 -0
- package/dist/2.0.8/codex/plugin/skills/write-test-code/references/anti-patterns.md +88 -0
- package/dist/2.0.8/codex/plugin/skills/write-test-code/references/api-setup-teardown.md +83 -0
- package/dist/2.0.8/codex/plugin/skills/write-test-code/references/auth-patterns.md +63 -0
- package/dist/2.0.8/codex/plugin/skills/write-test-code/references/mapping-tables.md +56 -0
- package/dist/2.0.8/codex/plugin/skills/write-test-code/references/network-interception.md +56 -0
- package/dist/2.0.8/release.json +18 -0
- package/dist/2.0.9/.agents/plugins/marketplace.json +14 -0
- package/dist/2.0.9/claude/plugin/.claude-plugin/plugin.json +20 -0
- package/dist/2.0.9/claude/plugin/package.json +9 -0
- package/dist/2.0.9/claude/plugin/skills/add-e2e-tests/SKILL.md +215 -0
- package/dist/2.0.9/claude/plugin/skills/add-e2e-tests/agents/claude.yaml +3 -0
- package/dist/2.0.9/claude/plugin/skills/add-e2e-tests/agents/openai.yaml +10 -0
- package/dist/2.0.9/claude/plugin/skills/add-e2e-tests/references/authentication.md +8 -0
- package/dist/2.0.9/claude/plugin/skills/add-e2e-tests/references/error-recovery.md +43 -0
- package/dist/2.0.9/claude/plugin/skills/add-e2e-tests/references/scaffolding.md +12 -0
- package/dist/2.0.9/claude/plugin/skills/add-e2e-tests/references/tracker-template.md +53 -0
- package/dist/2.0.9/claude/plugin/skills/analyze-test-codebase/SKILL.md +142 -0
- package/dist/2.0.9/claude/plugin/skills/analyze-test-codebase/agents/claude.yaml +3 -0
- package/dist/2.0.9/claude/plugin/skills/analyze-test-codebase/agents/openai.yaml +4 -0
- package/dist/2.0.9/claude/plugin/skills/fix-flaky-tests/SKILL.md +160 -0
- package/dist/2.0.9/claude/plugin/skills/fix-flaky-tests/agents/claude.yaml +3 -0
- package/dist/2.0.9/claude/plugin/skills/fix-flaky-tests/agents/openai.yaml +10 -0
- package/dist/2.0.9/claude/plugin/skills/fix-flaky-tests/references/fix-patterns.md +91 -0
- package/dist/2.0.9/claude/plugin/skills/generate-test-cases/SKILL.md +184 -0
- package/dist/2.0.9/claude/plugin/skills/generate-test-cases/agents/claude.yaml +3 -0
- package/dist/2.0.9/claude/plugin/skills/generate-test-cases/agents/openai.yaml +10 -0
- package/dist/2.0.9/claude/plugin/skills/generate-test-cases/references/scenario-categories.md +36 -0
- package/dist/2.0.9/claude/plugin/skills/plan-test-coverage/SKILL.md +117 -0
- package/dist/2.0.9/claude/plugin/skills/plan-test-coverage/agents/claude.yaml +3 -0
- package/dist/2.0.9/claude/plugin/skills/plan-test-coverage/agents/openai.yaml +10 -0
- package/dist/2.0.9/claude/plugin/skills/review-test-cases/SKILL.md +147 -0
- package/dist/2.0.9/claude/plugin/skills/review-test-cases/agents/claude.yaml +3 -0
- package/dist/2.0.9/claude/plugin/skills/review-test-cases/agents/openai.yaml +10 -0
- package/dist/2.0.9/claude/plugin/skills/review-test-code/SKILL.md +189 -0
- package/dist/2.0.9/claude/plugin/skills/review-test-code/agents/claude.yaml +3 -0
- package/dist/2.0.9/claude/plugin/skills/review-test-code/agents/openai.yaml +10 -0
- package/dist/2.0.9/claude/plugin/skills/write-test-code/SKILL.md +227 -0
- package/dist/2.0.9/claude/plugin/skills/write-test-code/agents/claude.yaml +3 -0
- package/dist/2.0.9/claude/plugin/skills/write-test-code/agents/openai.yaml +10 -0
- package/dist/2.0.9/claude/plugin/skills/write-test-code/references/anti-patterns.md +88 -0
- package/dist/2.0.9/claude/plugin/skills/write-test-code/references/api-setup-teardown.md +83 -0
- package/dist/2.0.9/claude/plugin/skills/write-test-code/references/auth-patterns.md +63 -0
- package/dist/2.0.9/claude/plugin/skills/write-test-code/references/mapping-tables.md +56 -0
- package/dist/2.0.9/claude/plugin/skills/write-test-code/references/network-interception.md +56 -0
- package/dist/2.0.9/codex/plugin/.codex-plugin/plugin.json +15 -0
- package/dist/2.0.9/codex/plugin/package.json +9 -0
- package/dist/2.0.9/codex/plugin/skills/add-e2e-tests/SKILL.md +215 -0
- package/dist/2.0.9/codex/plugin/skills/add-e2e-tests/agents/claude.yaml +3 -0
- package/dist/2.0.9/codex/plugin/skills/add-e2e-tests/agents/openai.yaml +10 -0
- package/dist/2.0.9/codex/plugin/skills/add-e2e-tests/references/authentication.md +8 -0
- package/dist/2.0.9/codex/plugin/skills/add-e2e-tests/references/error-recovery.md +43 -0
- package/dist/2.0.9/codex/plugin/skills/add-e2e-tests/references/scaffolding.md +12 -0
- package/dist/2.0.9/codex/plugin/skills/add-e2e-tests/references/tracker-template.md +53 -0
- package/dist/2.0.9/codex/plugin/skills/analyze-test-codebase/SKILL.md +142 -0
- package/dist/2.0.9/codex/plugin/skills/analyze-test-codebase/agents/claude.yaml +3 -0
- package/dist/2.0.9/codex/plugin/skills/analyze-test-codebase/agents/openai.yaml +4 -0
- package/dist/2.0.9/codex/plugin/skills/fix-flaky-tests/SKILL.md +160 -0
- package/dist/2.0.9/codex/plugin/skills/fix-flaky-tests/agents/claude.yaml +3 -0
- package/dist/2.0.9/codex/plugin/skills/fix-flaky-tests/agents/openai.yaml +10 -0
- package/dist/2.0.9/codex/plugin/skills/fix-flaky-tests/references/fix-patterns.md +91 -0
- package/dist/2.0.9/codex/plugin/skills/generate-test-cases/SKILL.md +184 -0
- package/dist/2.0.9/codex/plugin/skills/generate-test-cases/agents/claude.yaml +3 -0
- package/dist/2.0.9/codex/plugin/skills/generate-test-cases/agents/openai.yaml +10 -0
- package/dist/2.0.9/codex/plugin/skills/generate-test-cases/references/scenario-categories.md +36 -0
- package/dist/2.0.9/codex/plugin/skills/plan-test-coverage/SKILL.md +117 -0
- package/dist/2.0.9/codex/plugin/skills/plan-test-coverage/agents/claude.yaml +3 -0
- package/dist/2.0.9/codex/plugin/skills/plan-test-coverage/agents/openai.yaml +10 -0
- package/dist/2.0.9/codex/plugin/skills/review-test-cases/SKILL.md +147 -0
- package/dist/2.0.9/codex/plugin/skills/review-test-cases/agents/claude.yaml +3 -0
- package/dist/2.0.9/codex/plugin/skills/review-test-cases/agents/openai.yaml +10 -0
- package/dist/2.0.9/codex/plugin/skills/review-test-code/SKILL.md +189 -0
- package/dist/2.0.9/codex/plugin/skills/review-test-code/agents/claude.yaml +3 -0
- package/dist/2.0.9/codex/plugin/skills/review-test-code/agents/openai.yaml +10 -0
- package/dist/2.0.9/codex/plugin/skills/write-test-code/SKILL.md +227 -0
- package/dist/2.0.9/codex/plugin/skills/write-test-code/agents/claude.yaml +3 -0
- package/dist/2.0.9/codex/plugin/skills/write-test-code/agents/openai.yaml +10 -0
- package/dist/2.0.9/codex/plugin/skills/write-test-code/references/anti-patterns.md +88 -0
- package/dist/2.0.9/codex/plugin/skills/write-test-code/references/api-setup-teardown.md +83 -0
- package/dist/2.0.9/codex/plugin/skills/write-test-code/references/auth-patterns.md +63 -0
- package/dist/2.0.9/codex/plugin/skills/write-test-code/references/mapping-tables.md +56 -0
- package/dist/2.0.9/codex/plugin/skills/write-test-code/references/network-interception.md +56 -0
- package/dist/2.0.9/release.json +18 -0
- package/package.json +13 -0
- package/skills/add-e2e-tests/SKILL.md +215 -0
- package/skills/add-e2e-tests/agents/claude.yaml +3 -0
- package/skills/add-e2e-tests/agents/openai.yaml +10 -0
- package/skills/add-e2e-tests/references/authentication.md +8 -0
- package/skills/add-e2e-tests/references/error-recovery.md +43 -0
- package/skills/add-e2e-tests/references/scaffolding.md +12 -0
- package/skills/add-e2e-tests/references/tracker-template.md +53 -0
- package/skills/analyze-test-codebase/SKILL.md +142 -0
- package/skills/analyze-test-codebase/agents/claude.yaml +3 -0
- package/skills/analyze-test-codebase/agents/openai.yaml +4 -0
- package/skills/fix-flaky-tests/SKILL.md +160 -0
- package/skills/fix-flaky-tests/agents/claude.yaml +3 -0
- package/skills/fix-flaky-tests/agents/openai.yaml +10 -0
- package/skills/fix-flaky-tests/references/fix-patterns.md +91 -0
- package/skills/generate-test-cases/SKILL.md +184 -0
- package/skills/generate-test-cases/agents/claude.yaml +3 -0
- package/skills/generate-test-cases/agents/openai.yaml +10 -0
- package/skills/generate-test-cases/references/scenario-categories.md +36 -0
- package/skills/plan-test-coverage/SKILL.md +117 -0
- package/skills/plan-test-coverage/agents/claude.yaml +3 -0
- package/skills/plan-test-coverage/agents/openai.yaml +10 -0
- package/skills/review-test-cases/SKILL.md +147 -0
- package/skills/review-test-cases/agents/claude.yaml +3 -0
- package/skills/review-test-cases/agents/openai.yaml +10 -0
- package/skills/review-test-code/SKILL.md +189 -0
- package/skills/review-test-code/agents/claude.yaml +3 -0
- package/skills/review-test-code/agents/openai.yaml +10 -0
- package/skills/write-test-code/SKILL.md +227 -0
- package/skills/write-test-code/agents/claude.yaml +3 -0
- package/skills/write-test-code/agents/openai.yaml +10 -0
- package/skills/write-test-code/references/anti-patterns.md +88 -0
- package/skills/write-test-code/references/api-setup-teardown.md +83 -0
- package/skills/write-test-code/references/auth-patterns.md +63 -0
- package/skills/write-test-code/references/mapping-tables.md +56 -0
- package/skills/write-test-code/references/network-interception.md +56 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Error Recovery for Infrastructure Failures
|
|
2
|
+
|
|
3
|
+
When infrastructure failures occur during E2E test building, follow the general pattern: diagnose, attempt one known fix, if still stuck record in tracker and ask the user.
|
|
4
|
+
|
|
5
|
+
## Browser MCP unavailable
|
|
6
|
+
|
|
7
|
+
The browser MCP server (`agent-web-interface`) must be running for site exploration.
|
|
8
|
+
|
|
9
|
+
1. Verify the MCP server is configured in the project (check `.mcp.json` or plugin config).
|
|
10
|
+
2. Ask the user to confirm the MCP server is running or to restart it.
|
|
11
|
+
3. If unreachable after user intervention, mark the session as blocked: `<!-- E2E_BLOCKED: browser MCP server unreachable -->`.
|
|
12
|
+
|
|
13
|
+
## Boilerplate clone fails
|
|
14
|
+
|
|
15
|
+
When `git clone git@github.com:lespaceman/playwright-typescript-e2e-boilerplate.git` fails:
|
|
16
|
+
|
|
17
|
+
1. Check if SSH keys are configured — the error will usually indicate `Permission denied (publickey)`.
|
|
18
|
+
2. Fall back to HTTPS: `git clone https://github.com/lespaceman/playwright-typescript-e2e-boilerplate.git`.
|
|
19
|
+
3. If both fail, ask the user to verify network access and GitHub authentication.
|
|
20
|
+
|
|
21
|
+
## npm install fails
|
|
22
|
+
|
|
23
|
+
1. Check the Node.js version — Playwright requires Node 18+. Run `node --version`.
|
|
24
|
+
2. Clear the npm cache: `npm cache clean --force`.
|
|
25
|
+
3. Check for lockfile conflicts — if both `package-lock.json` and `yarn.lock` exist, ask the user which package manager to use.
|
|
26
|
+
4. If dependency resolution fails, try `npm install --legacy-peer-deps` as a fallback.
|
|
27
|
+
|
|
28
|
+
## Playwright browser install fails
|
|
29
|
+
|
|
30
|
+
When `npx playwright install --with-deps chromium` fails:
|
|
31
|
+
|
|
32
|
+
1. Try installing just chromium without system deps: `npx playwright install chromium`.
|
|
33
|
+
2. Check permissions — on Linux, system dependency installation may require sudo.
|
|
34
|
+
3. If behind a corporate proxy, ask the user for proxy configuration.
|
|
35
|
+
4. As a last resort, ask the user to run the install command manually and confirm when done.
|
|
36
|
+
|
|
37
|
+
## General pattern
|
|
38
|
+
|
|
39
|
+
For any infrastructure failure not listed above:
|
|
40
|
+
|
|
41
|
+
1. **Diagnose** — read the error message carefully, check logs, identify the root cause.
|
|
42
|
+
2. **Attempt one known fix** — apply the most likely solution based on the error.
|
|
43
|
+
3. **If still stuck** — record the full error output and diagnostic steps taken in the tracker, then ask the user for help. Do not loop through multiple speculative fixes.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Scaffolding Playwright from Boilerplate
|
|
2
|
+
|
|
3
|
+
If Playwright is not set up in the target project, follow this procedure:
|
|
4
|
+
|
|
5
|
+
1. Clone `git@github.com:lespaceman/playwright-typescript-e2e-boilerplate.git` into a temporary directory.
|
|
6
|
+
2. Copy config, fixtures, pages, and utils into the project. Do not overwrite existing files.
|
|
7
|
+
3. Update `baseURL` to the target URL and remove example tests.
|
|
8
|
+
- **Test execution strategy:** If the project needs role-based or category-based test filtering, configure it via Playwright `--grep` tags or file naming conventions (`*.admin.spec.ts`), NOT via `testIgnore` regex patterns. A `testIgnore` regex becomes a maintenance trap — every new test file requires updating the regex. If the boilerplate includes a `testIgnore` regex, replace it with tag-based filtering.
|
|
9
|
+
4. Merge devDependencies into `package.json`.
|
|
10
|
+
5. Run `npm install && npx playwright install --with-deps chromium`.
|
|
11
|
+
6. Clean up the temp clone.
|
|
12
|
+
7. Log all scaffolding steps in the tracker.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Tracker Template: e2e-tracker.md
|
|
2
|
+
|
|
3
|
+
Use this as a starting template when creating the tracker file. Adapt sections as needed.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
```markdown
|
|
8
|
+
# E2E Test Tracker
|
|
9
|
+
|
|
10
|
+
## Goal
|
|
11
|
+
|
|
12
|
+
- **URL:** https://myapp.com/checkout
|
|
13
|
+
- **Feature:** Checkout flow with cart, shipping, and payment
|
|
14
|
+
- **Slug:** checkout
|
|
15
|
+
|
|
16
|
+
## Progress
|
|
17
|
+
|
|
18
|
+
### Session 1 — 2026-04-01
|
|
19
|
+
|
|
20
|
+
- Analyzed codebase: Playwright 1.42, TypeScript, existing auth fixture in `tests/fixtures/auth.ts`
|
|
21
|
+
- Browsed checkout flow: 4-step wizard (cart review, shipping, payment, confirmation)
|
|
22
|
+
- Discovered 3 form validation states per step
|
|
23
|
+
- Generated test spec: `test-cases/checkout.md` with TC-CHECKOUT-001 through TC-CHECKOUT-012
|
|
24
|
+
- Review gate passed with warnings (TC-CHECKOUT-008 needs clarification on coupon edge case)
|
|
25
|
+
|
|
26
|
+
### Session 2 — 2026-04-02
|
|
27
|
+
|
|
28
|
+
- Wrote `tests/checkout.spec.ts` covering TC-CHECKOUT-001 through TC-CHECKOUT-012
|
|
29
|
+
- Code review gate passed
|
|
30
|
+
- Ran tests: 10/12 passing, 2 failing (TC-CHECKOUT-006: selector stale, TC-CHECKOUT-011: timeout)
|
|
31
|
+
- Fixed TC-CHECKOUT-006: updated selector from `.price` to `[data-testid="cart-total"]`
|
|
32
|
+
- Fixed TC-CHECKOUT-011: added `waitForResponse` before assertion
|
|
33
|
+
|
|
34
|
+
## Remaining
|
|
35
|
+
|
|
36
|
+
- Re-run full suite to confirm fixes
|
|
37
|
+
- Verify TC-ID coverage: all 12 specs should map to test code
|
|
38
|
+
|
|
39
|
+
## Next Steps
|
|
40
|
+
|
|
41
|
+
- Run `npx playwright test tests/checkout.spec.ts --reporter=list` and record output
|
|
42
|
+
- If all green, mark complete
|
|
43
|
+
- If failures remain, diagnose with `fix-flaky-tests` skill
|
|
44
|
+
|
|
45
|
+
<!-- E2E_COMPLETE -->
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
**Terminal markers** (write as the last line of the tracker when appropriate):
|
|
51
|
+
|
|
52
|
+
- `<!-- E2E_COMPLETE -->` — all tests pass, all TC-IDs covered, work is done
|
|
53
|
+
- `<!-- E2E_BLOCKED: reason -->` — unrecoverable blocker prevents further progress (e.g., `<!-- E2E_BLOCKED: login requires 2FA token we cannot automate -->`)
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: analyze-test-codebase
|
|
3
|
+
description: >
|
|
4
|
+
Scans and reports on an existing Playwright test codebase. This skill should be used to inspect
|
|
5
|
+
the current Playwright setup before writing, reviewing, or fixing tests, and should be loaded
|
|
6
|
+
early when working in a new project to understand existing patterns. Covers: Playwright config,
|
|
7
|
+
page objects, fixtures, helpers, auth/globalSetup patterns, test conventions, and directory
|
|
8
|
+
structure. Triggers: "understand", "check", "show me", "inspect", or "analyze"
|
|
9
|
+
the current test setup, config, infrastructure, patterns, or conventions. In the full add-tests
|
|
10
|
+
workflow, this skill serves as an early read-only analysis sub-step before planning detailed
|
|
11
|
+
coverage or writing code. This skill examines existing files and outputs a structured report.
|
|
12
|
+
It does NOT write or fix tests, install Playwright, or explore live websites — for live site
|
|
13
|
+
exploration, use agent-web-interface-guide instead.
|
|
14
|
+
allowed-tools: Read Glob Grep Bash
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Analyze Test Codebase
|
|
18
|
+
|
|
19
|
+
Scan and analyze an existing Playwright test codebase to understand its conventions, configuration, and patterns before writing new tests.
|
|
20
|
+
|
|
21
|
+
## Workflow
|
|
22
|
+
|
|
23
|
+
1. **Locate Playwright configuration** — search for `playwright.config.ts`, `playwright.config.js`, or `playwright.config.mjs` in the project root and common subdirectories.
|
|
24
|
+
|
|
25
|
+
2. **Extract configuration details**:
|
|
26
|
+
- `baseURL` — the target application URL
|
|
27
|
+
- `testDir` — where tests live
|
|
28
|
+
- `projects` — browser/device configurations
|
|
29
|
+
- `use` — default options (viewport, headless, trace, screenshot)
|
|
30
|
+
- `webServer` — if Playwright starts the app
|
|
31
|
+
- `globalSetup` / `globalTeardown` — auth or data seeding scripts
|
|
32
|
+
- `reporter` — configured reporters
|
|
33
|
+
|
|
34
|
+
3. **Scan test directory structure**:
|
|
35
|
+
```
|
|
36
|
+
Glob for **/*.spec.ts, **/*.test.ts, **/*.spec.js, **/*.test.js
|
|
37
|
+
```
|
|
38
|
+
- Count total test files
|
|
39
|
+
- Identify naming conventions (`.spec.ts` vs `.test.ts`)
|
|
40
|
+
- Map directory organization (by feature? by page? flat?)
|
|
41
|
+
|
|
42
|
+
4. **Detect patterns in existing tests** — read 2-3 representative test files and identify:
|
|
43
|
+
- **Locator strategy**: `getByRole`, `getByTestId`, CSS selectors, XPath
|
|
44
|
+
- **Wait strategy**: auto-waits, explicit `waitFor*`, any `waitForTimeout` (flag these)
|
|
45
|
+
- **Test structure**: AAA pattern, describe/test nesting, use of `test.step`
|
|
46
|
+
- **Data management**: fixtures, test data files, factory functions
|
|
47
|
+
- **Page Objects**: POM pattern usage, fixture-based injection
|
|
48
|
+
- **Auth handling**: `storageState`, global setup, per-test login
|
|
49
|
+
- **Custom fixtures**: extended `test` with custom fixtures
|
|
50
|
+
- **Helper utilities**: shared functions, custom assertions
|
|
51
|
+
- **Network mocking**: `page.route()` usage, HAR recording (`routeFromHAR`), API interceptors
|
|
52
|
+
- **Visual regression**: `toHaveScreenshot()`, `toMatchSnapshot()`, snapshot directories
|
|
53
|
+
- **Accessibility testing**: `@axe-core/playwright` usage, custom a11y assertions
|
|
54
|
+
- **Cross-browser config**: multiple projects in playwright.config (chromium, firefox, webkit)
|
|
55
|
+
- **Retry configuration**: `retries` count, trace settings (`on-first-retry`)
|
|
56
|
+
- **Parallelism**: `fullyParallel`, `workers` count, test isolation strategy
|
|
57
|
+
|
|
58
|
+
5. **Check for supporting infrastructure**:
|
|
59
|
+
- `fixtures/` or `helpers/` directories
|
|
60
|
+
- `pages/` or `pom/` (Page Object Model)
|
|
61
|
+
- `.env` or `.env.test` files (test-specific environment configuration)
|
|
62
|
+
- CI configuration (`.github/workflows/`, `Jenkinsfile`, etc.)
|
|
63
|
+
- `package.json` scripts for running tests
|
|
64
|
+
- `*.har` files or HAR directories (recorded API responses for mocking)
|
|
65
|
+
- Snapshot directories (`__snapshots__`, `screenshots/`) for visual regression baselines
|
|
66
|
+
- Docker or `docker-compose` for test environment setup
|
|
67
|
+
- Global setup/teardown scripts — what they do (auth, seeding, cleanup)
|
|
68
|
+
|
|
69
|
+
6. **Generate report** — output a structured summary:
|
|
70
|
+
|
|
71
|
+
```markdown
|
|
72
|
+
## Test Codebase Analysis
|
|
73
|
+
|
|
74
|
+
### Framework
|
|
75
|
+
- **Playwright** version X.Y.Z
|
|
76
|
+
- Config: `playwright.config.ts`
|
|
77
|
+
- Test directory: `tests/`
|
|
78
|
+
|
|
79
|
+
### Conventions
|
|
80
|
+
- File naming: `*.spec.ts`
|
|
81
|
+
- Locator preference: getByRole > getByTestId
|
|
82
|
+
- Structure: describe blocks by feature
|
|
83
|
+
- Page Objects: Yes, in `tests/pages/`
|
|
84
|
+
- Custom fixtures: Yes, in `tests/fixtures/`
|
|
85
|
+
|
|
86
|
+
### Auth
|
|
87
|
+
- Method: storageState via global setup
|
|
88
|
+
- Auth file: `tests/.auth/user.json`
|
|
89
|
+
|
|
90
|
+
### Existing Coverage
|
|
91
|
+
- Total test files: N
|
|
92
|
+
- Feature areas covered: [list]
|
|
93
|
+
- Test count: ~N tests
|
|
94
|
+
|
|
95
|
+
### Network Mocking
|
|
96
|
+
- Method: page.route() / HAR / none
|
|
97
|
+
- Patterns: [list any existing mocking patterns]
|
|
98
|
+
|
|
99
|
+
### Visual Testing
|
|
100
|
+
- Enabled: Yes/No
|
|
101
|
+
- Tool: toHaveScreenshot() / third-party / none
|
|
102
|
+
- Baseline directory: [path if exists]
|
|
103
|
+
|
|
104
|
+
### Accessibility Testing
|
|
105
|
+
- Enabled: Yes/No
|
|
106
|
+
- Tool: @axe-core/playwright / custom assertions / none
|
|
107
|
+
|
|
108
|
+
### Cross-Browser & CI
|
|
109
|
+
- Browser projects: [list from config]
|
|
110
|
+
- Retries: N (CI) / N (local)
|
|
111
|
+
- Workers: N / fullyParallel: Yes/No
|
|
112
|
+
- CI platform: GitHub Actions / Jenkins / none detected
|
|
113
|
+
- Trace: [setting from config]
|
|
114
|
+
|
|
115
|
+
### Recommendations for New Tests
|
|
116
|
+
- Follow existing `*.spec.ts` naming
|
|
117
|
+
- Use page objects from `tests/pages/`
|
|
118
|
+
- Import test data from `tests/fixtures/testData.ts`
|
|
119
|
+
- Use `baseURL` for navigation (relative paths)
|
|
120
|
+
- Auth: reuse existing storageState setup
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Out of Scope
|
|
124
|
+
|
|
125
|
+
This skill only reads and reports on the codebase. For related tasks, use the appropriate skill:
|
|
126
|
+
|
|
127
|
+
| Task | Skill |
|
|
128
|
+
|------|-------|
|
|
129
|
+
| Browsing a live site, interacting with UI elements | `agent-web-interface-guide` |
|
|
130
|
+
| Deciding what to test, coverage gaps, priorities | `plan-test-coverage` |
|
|
131
|
+
| Writing or modifying executable test code | `write-test-code` |
|
|
132
|
+
| Diagnosing flaky or failing tests | `fix-flaky-tests` |
|
|
133
|
+
|
|
134
|
+
## Example Usage
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
Claude Code: /analyze-test-codebase
|
|
138
|
+
Codex: $analyze-test-codebase
|
|
139
|
+
|
|
140
|
+
Claude Code: /analyze-test-codebase ./my-app
|
|
141
|
+
Codex: $analyze-test-codebase ./my-app
|
|
142
|
+
```
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "Analyze Existing Test Setup"
|
|
3
|
+
short_description: "Inspect Playwright conventions before planning or writing tests"
|
|
4
|
+
default_prompt: "Analyze this Playwright codebase and summarize the current setup as an early workflow step before planning detailed coverage or writing test code."
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fix-flaky-tests
|
|
3
|
+
description: >
|
|
4
|
+
This skill should be used when a Playwright test is failing, flaky, timing out, or behaving
|
|
5
|
+
inconsistently. It provides structured root cause analysis for: stabilizing intermittent tests,
|
|
6
|
+
debugging timeouts ("Test timeout of 30000ms exceeded"), fixing race conditions, investigating
|
|
7
|
+
local-vs-CI divergence, running repeated stability checks (--repeat-each).
|
|
8
|
+
IMPORTANT: If running tests with --repeat-each, --retries, or multiple times to check stability,
|
|
9
|
+
STOP and load this skill first — it has structured root cause analysis that prevents brute-force
|
|
10
|
+
approaches. Triggers: "stabilize", "intermittent", "flaky", "keeps failing", "fails in CI",
|
|
11
|
+
"timeout on", "race condition", "run N times to check stability", "verify tests are stable".
|
|
12
|
+
NOT for writing new tests (use write-test-code) or analyzing setup (use analyze-test-codebase).
|
|
13
|
+
allowed-tools: Read Write Edit Bash Glob Grep Task
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Fix Flaky Tests
|
|
17
|
+
|
|
18
|
+
Systematically diagnose and fix intermittent Playwright test failures using root cause analysis. A flaky test is worse than no test — it trains teams to ignore failures.
|
|
19
|
+
|
|
20
|
+
## Input
|
|
21
|
+
|
|
22
|
+
Parse the test file path or test name from: $ARGUMENTS
|
|
23
|
+
|
|
24
|
+
If no argument provided, ask: "Which test file or test name is flaky?"
|
|
25
|
+
|
|
26
|
+
## Workflow
|
|
27
|
+
|
|
28
|
+
### Step 1: Reproduce and Classify
|
|
29
|
+
|
|
30
|
+
1. **Read the test file** to understand what it tests and how
|
|
31
|
+
2. **Run the test multiple times** to observe the failure pattern:
|
|
32
|
+
```bash
|
|
33
|
+
npx playwright test <file> --repeat-each=5 --reporter=list 2>&1
|
|
34
|
+
```
|
|
35
|
+
3. **Run in isolation** if it passed above — it may only fail with other tests:
|
|
36
|
+
```bash
|
|
37
|
+
npx playwright test --reporter=list 2>&1
|
|
38
|
+
```
|
|
39
|
+
4. **Classify the failure** into one of these root cause categories:
|
|
40
|
+
|
|
41
|
+
| Category | Symptoms |
|
|
42
|
+
|----------|----------|
|
|
43
|
+
| **Timing** | Timeout errors, "element not found", "not visible yet" |
|
|
44
|
+
| **State leakage** | Passes alone, fails when run with other tests |
|
|
45
|
+
| **Data dependency** | Fails when expected data doesn't exist or has changed |
|
|
46
|
+
| **Race condition** | Action fires before page is ready (hydration, animation) |
|
|
47
|
+
| **Selector fragility** | Element found but wrong one, or `.first()` picks different element |
|
|
48
|
+
| **Environment** | Passes locally, fails in CI (viewport, speed, resources) |
|
|
49
|
+
|
|
50
|
+
### Step 2: Root Cause Analysis
|
|
51
|
+
|
|
52
|
+
Investigate based on the classification:
|
|
53
|
+
|
|
54
|
+
**Timing issues:**
|
|
55
|
+
- Look for assertions immediately after actions with no wait for the resulting state change
|
|
56
|
+
- Check if the test asserts before an API response arrives — search for missing `waitForResponse`
|
|
57
|
+
- Look for animations/transitions that affect element state (CSS transitions, skeleton screens)
|
|
58
|
+
- Check for `waitForTimeout` being used as a "fix" — this is a symptom, not a cure
|
|
59
|
+
- Check if `networkidle` or `load` waitUntil would help for navigation
|
|
60
|
+
|
|
61
|
+
**State leakage:**
|
|
62
|
+
- Run the failing test alone: `npx playwright test --grep "<test name>"`
|
|
63
|
+
- Check if tests share mutable state: global variables, database rows, cookies, localStorage
|
|
64
|
+
- Look for missing cleanup in `afterEach`/`afterAll`
|
|
65
|
+
- Check if `storageState` bleeds between tests or test files
|
|
66
|
+
- Check for test data created by one test that another test depends on
|
|
67
|
+
|
|
68
|
+
**Race conditions:**
|
|
69
|
+
- Identify the race: what two things are happening concurrently?
|
|
70
|
+
- Check for click handlers that fire before JavaScript hydration completes
|
|
71
|
+
- Look for optimistic UI updates that revert on API response
|
|
72
|
+
- Check for actions during navigation transitions (click during page load)
|
|
73
|
+
- Look for double-clicks or rapid interactions that trigger duplicate actions
|
|
74
|
+
|
|
75
|
+
**Selector fragility:**
|
|
76
|
+
- Navigate to the page in the browser and verify the selector currently matches the intended element
|
|
77
|
+
- Check if the selector matches multiple elements — `.first()` or `.nth()` is a smell
|
|
78
|
+
- Look for dynamically generated IDs, classes, or attributes
|
|
79
|
+
- Check for conditional rendering that changes element order or presence
|
|
80
|
+
- Verify locators against current DOM structure using `find` and `get_element`
|
|
81
|
+
|
|
82
|
+
**Environment issues:**
|
|
83
|
+
- Compare CI viewport size vs local — element may be off-screen in CI
|
|
84
|
+
- Check for timezone-dependent assertions (dates, timestamps)
|
|
85
|
+
- Check for locale-dependent formatting (numbers, currency)
|
|
86
|
+
- Check if CI has slower network/CPU affecting timing
|
|
87
|
+
- Look for third-party scripts (analytics, chat widgets) that load differently in CI
|
|
88
|
+
|
|
89
|
+
### Step 3: Apply the Correct Fix
|
|
90
|
+
|
|
91
|
+
Use the right fix pattern for the diagnosed root cause. **Never apply a fix without understanding the cause.** See [references/fix-patterns.md](references/fix-patterns.md) for full code examples.
|
|
92
|
+
|
|
93
|
+
| Category | Principle |
|
|
94
|
+
|----------|-----------|
|
|
95
|
+
| **Timing** | Replace sleeps with event-driven waits (`waitForResponse`, auto-retrying assertions) |
|
|
96
|
+
| **State isolation** | Unique data per test, API-based reset in `beforeEach`, no shared mutable state |
|
|
97
|
+
| **Race condition** | Use `Promise.all` for action + expected response; wait for hydration before interaction |
|
|
98
|
+
| **Selector** | Scope locators to containers with unique content; avoid `.first()` and position-dependent selectors |
|
|
99
|
+
| **Environment** | Explicit viewport, timezone-agnostic assertions, block interfering third-party scripts |
|
|
100
|
+
|
|
101
|
+
### Step 4: Verify the Fix
|
|
102
|
+
|
|
103
|
+
1. **Run the test 5+ times** to confirm stability:
|
|
104
|
+
```bash
|
|
105
|
+
npx playwright test <file> --repeat-each=5 --reporter=list 2>&1
|
|
106
|
+
```
|
|
107
|
+
2. **Run with the full test suite** to verify no state leakage:
|
|
108
|
+
```bash
|
|
109
|
+
npx playwright test --reporter=list 2>&1
|
|
110
|
+
```
|
|
111
|
+
3. If still flaky → return to Step 2 with the new failure output. The initial classification may have been wrong.
|
|
112
|
+
4. **Maximum 3 fix-and-rerun cycles.** If the test is still flaky after 3 attempts, stop and report the diagnostic findings (root cause hypothesis, fixes attempted, remaining failure output) so the user can decide next steps. Do not continue looping.
|
|
113
|
+
|
|
114
|
+
### Step 5: Summarize
|
|
115
|
+
|
|
116
|
+
Report:
|
|
117
|
+
1. **Root cause** — what made the test flaky and why
|
|
118
|
+
2. **Fix applied** — what changed and why this fix addresses the root cause
|
|
119
|
+
3. **Verification** — how many consecutive runs passed
|
|
120
|
+
4. **Prevention** — what pattern to follow in future tests to avoid this class of flakiness
|
|
121
|
+
|
|
122
|
+
## Flakiness Checklist (Less Obvious Causes)
|
|
123
|
+
|
|
124
|
+
When the standard categories don't fit, check these:
|
|
125
|
+
|
|
126
|
+
- [ ] **Viewport size** — element off-screen in CI (smaller viewport)
|
|
127
|
+
- [ ] **Font rendering** — text matching fails due to font differences across OS
|
|
128
|
+
- [ ] **Timezone** — date/time assertions fail in different timezones
|
|
129
|
+
- [ ] **Locale** — number/currency formatting differs (1,000 vs 1.000)
|
|
130
|
+
- [ ] **Third-party scripts** — analytics/chat widgets change DOM or block clicks
|
|
131
|
+
- [ ] **Cookie consent banners** — overlay blocks click targets
|
|
132
|
+
- [ ] **Feature flags** — different features enabled in different environments
|
|
133
|
+
- [ ] **Database state** — shared test database with stale or conflicting data
|
|
134
|
+
- [ ] **Parallel execution** — tests interfere when run in parallel workers
|
|
135
|
+
- [ ] **Browser caching** — cached responses differ from fresh ones
|
|
136
|
+
- [ ] **Service workers** — intercepting requests differently than expected
|
|
137
|
+
- [ ] **Lazy loading** — elements not yet in DOM when test tries to interact
|
|
138
|
+
|
|
139
|
+
## Anti-Patterns: What is NOT a Fix
|
|
140
|
+
|
|
141
|
+
These mask the problem. Never apply them without a real fix:
|
|
142
|
+
|
|
143
|
+
| "Fix" | Why It's Wrong | Real Fix |
|
|
144
|
+
|-------|---------------|----------|
|
|
145
|
+
| `waitForTimeout(3000)` | Hides timing race, will break under load | Wait for the specific event |
|
|
146
|
+
| `.first()` added | Hides selector ambiguity | Narrow the selector |
|
|
147
|
+
| Increased timeout to 30s | Hides missing wait or slow setup | Find what you're actually waiting for |
|
|
148
|
+
| `test.skip()` | Ignoring the problem | Diagnose and fix |
|
|
149
|
+
| `retries: 3` without fix | Masks real failures, wastes CI time | Fix the root cause, then keep retries as safety net |
|
|
150
|
+
| `{ force: true }` | Bypasses actionability checks, hides overlapping elements or disabled state | Find and fix the actionability issue: wait for overlay to disappear, scroll element into view, or wait for enabled state |
|
|
151
|
+
| `try/catch` swallowing errors | Test passes but doesn't verify anything | Fix the assertion |
|
|
152
|
+
|
|
153
|
+
## Multiple Flaky Tests
|
|
154
|
+
|
|
155
|
+
When a suite has several flaky tests:
|
|
156
|
+
|
|
157
|
+
1. **Triage first.** Run the full suite once and group failures by root cause category (timing, state leakage, etc.). Shared root causes (broken fixture, leaking state) should be fixed once, not per-test.
|
|
158
|
+
2. **Fix shared infrastructure issues first.** A bad `beforeEach`, a leaking `storageState`, or a missing cleanup can cause many tests to fail. One fix resolves many failures.
|
|
159
|
+
3. **Split independent fixes across subagents** when the fix scopes do not overlap (different test files, no shared fixtures). Pass each subagent the test file path, this diagnostic workflow, and the root cause classification table.
|
|
160
|
+
4. The 3 fix-and-rerun cycle limit applies **per test**, not globally.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "Fix Flaky Playwright Tests"
|
|
3
|
+
short_description: "Diagnose unstable Playwright tests and fix the root cause"
|
|
4
|
+
default_prompt: "Diagnose this flaky Playwright test, reproduce the failure, and fix the root cause."
|
|
5
|
+
|
|
6
|
+
dependencies:
|
|
7
|
+
tools:
|
|
8
|
+
- type: "mcp"
|
|
9
|
+
value: "agent-web-interface"
|
|
10
|
+
description: "Browser automation MCP used to reproduce and inspect unstable flows"
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Fix Patterns by Root Cause
|
|
2
|
+
|
|
3
|
+
Code examples for each root cause category. Apply only after diagnosing the cause in Step 2.
|
|
4
|
+
|
|
5
|
+
## Timing Fixes — Replace Sleeps with Event-Driven Waits
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// BAD: arbitrary sleep
|
|
9
|
+
await page.waitForTimeout(2000);
|
|
10
|
+
await expect(element).toBeVisible();
|
|
11
|
+
|
|
12
|
+
// GOOD: wait for the network event that loads the content
|
|
13
|
+
await page.waitForResponse(resp => resp.url().includes('/api/data'));
|
|
14
|
+
await expect(element).toBeVisible();
|
|
15
|
+
|
|
16
|
+
// GOOD: wait for loading indicator to disappear
|
|
17
|
+
await expect(page.getByRole('progressbar')).toBeHidden();
|
|
18
|
+
await expect(element).toBeVisible();
|
|
19
|
+
|
|
20
|
+
// GOOD: wait for navigation to complete
|
|
21
|
+
await page.goto('/page', { waitUntil: 'networkidle' });
|
|
22
|
+
|
|
23
|
+
// GOOD: use auto-retrying assertion (retries until timeout)
|
|
24
|
+
await expect(page.getByText(/loaded/i)).toBeVisible({ timeout: 10000 });
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## State Isolation Fixes
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
// Unique data per test
|
|
31
|
+
const uniqueEmail = `test-${Date.now()}@example.com`;
|
|
32
|
+
|
|
33
|
+
// Reset state via API before each test
|
|
34
|
+
test.beforeEach(async ({ request }) => {
|
|
35
|
+
await request.post('/api/test/reset');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Use fresh browser context (default in Playwright, but verify)
|
|
39
|
+
// Do NOT share page or context between tests
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Race Condition Fixes
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// Wait for hydration/framework readiness
|
|
46
|
+
await page.waitForFunction(() =>
|
|
47
|
+
document.querySelector('[data-hydrated="true"]')
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// Use Promise.all for action + expected response
|
|
51
|
+
const [response] = await Promise.all([
|
|
52
|
+
page.waitForResponse('**/api/submit'),
|
|
53
|
+
submitButton.click(),
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
// Wait for animation/transition to complete
|
|
57
|
+
await expect(modal).toBeVisible();
|
|
58
|
+
await page.waitForFunction(() =>
|
|
59
|
+
!document.querySelector('.modal-animating')
|
|
60
|
+
);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Selector Fixes
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
// BAD: position-dependent, matches wrong element if order changes
|
|
67
|
+
page.locator('.item').first();
|
|
68
|
+
|
|
69
|
+
// GOOD: scoped to container with unique content
|
|
70
|
+
page.getByRole('listitem').filter({ hasText: 'Specific Item' });
|
|
71
|
+
|
|
72
|
+
// GOOD: use test IDs for ambiguous elements
|
|
73
|
+
page.getByTestId('cart-item-sku-123');
|
|
74
|
+
|
|
75
|
+
// GOOD: scope to a region first, then find within
|
|
76
|
+
page.locator('main').getByRole('button', { name: /submit/i });
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Environment Fixes
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
// Set explicit viewport in test or config
|
|
83
|
+
test.use({ viewport: { width: 1280, height: 720 } });
|
|
84
|
+
|
|
85
|
+
// Use timezone-agnostic assertions
|
|
86
|
+
await expect(dateElement).toContainText(/\d{4}/); // year, not full date string
|
|
87
|
+
|
|
88
|
+
// Block third-party scripts that interfere
|
|
89
|
+
await page.route('**/analytics/**', route => route.abort());
|
|
90
|
+
await page.route('**/chat-widget/**', route => route.abort());
|
|
91
|
+
```
|