Fixes failing or broken E2E tests. Diagnoses failures, fixes intercepts, selectors, page objects, and wait patterns. Surfaces architectural issues for human review. Use when E2E or Cypress tests are failing after a change.
Arguments: $ARGUMENTS (optional: path to specific test file or error description)
Call test-context scoped to the E2E directory to get intercept patterns, page object conventions, and wait strategy.
If a CI URL is provided in $ARGUMENTS: fetch CI logs using gh run view.
If a test file is provided: run it directly.
Otherwise: run the E2E suite and capture failures.
cd packages/e2e # or equivalent in this repo
pnpm cypress run --spec "${TEST_FILE:-**/*.cy.ts}" --headless 2>&1 | tee /tmp/e2e-output.txt
Always check screenshots first:
ls -lt cypress/screenshots/**/*.png 2>/dev/null | head -5
Read screenshots with the Read tool. They often reveal the real state at failure time.
Then check error type:
| Error | Investigation |
|---|---|
| Element not found | Compare selector in test/page-object vs actual DOM attributes |
| Timeout waiting for element | Check if network intercept is set up before the action that triggers it |
| Wrong URL after navigation | Check if page object submit() uses network synchronization |
| API returned unexpected data | Check if test data setup is correct; check if intercept mock matches actual response shape |
| Test passes locally, fails in CI | Check for hardcoded ports, environment-specific URLs, timing differences |
Priority order:
Fix in order of priority. Common fixes:
data-* attributecy.intercept() before the action that triggers the requestcy.wait(N) with cy.wait('@alias') or a condition assertionsubmit() methodRules:
cy.wait(N) — find the right condition to wait for.only to isolate the failing test before fixing; remove it after confirming# Run isolated test first
pnpm cypress run --spec "{fixed-test-file}" --headless 2>&1 | tail -30
Only run broader suite after isolated test passes.
## E2E Test Cleanup Complete
Fixed ({count}):
- {test name}: {root cause} → {fix applied}
Surfaced for review ({count}):
- {test name}: {why it needs human decision}
REPO=$(git remote get-url origin 2>/dev/null | sed 's/.*\///' | sed 's/\.git//')
BRANCH=$(git branch --show-current 2>/dev/null | sed 's/\//-/g')
TS=$(date +%Y%m%d-%H%M%S)-$$
mkdir -p ~/.claude/skill-output/$REPO/$BRANCH
Write this report to ~/.claude/skill-output/$REPO/$BRANCH/cleanup-e2e-tests-report-$TS.md.