End to end testing

From kid-sid/codex-spellbook · View interactive version

End to end testing is an AI agent skill from the GitHub repository kid-sid/codex-spellbook. End-to-end (E2E) testing patterns for user journeys, browser automation, UI state, and production-like environment validation. Use when testing the system as a black box from the user's perspective.

How to use this skill

Skill file

End-to-End Testing

Validate complete user workflows across the entire stack, ensuring that UI components, APIs, and databases work together in a production-like environment.

When to Activate

Selector Strategy

| Type | Example | Stability | Recommendation |

| --- | --- | --- | --- |

| User-facing (ARIA) | getByRole("button", { name: "Submit" }) | High | Primary: Tests what the user sees |

| Data attribute | getByTestId("submit-btn") | Medium | Secondary: Use when ARIA is ambiguous |

| CSS Class/ID | locator(".btn-primary") | Low | Avoid: Highly coupled to styling |

Execution Strategy

| Concern | Strategy |

| --- | --- |

| Test Data | Use a dedicated setup API or direct DB seed before each run |

| State Isolation | Clean cookies, localStorage, and indexedDB between tests |

| Waiting | Use auto-waiting or "Wait for State" (loading spinner gone) over hard sleeps |

BAD

// Flaky and coupled to implementation
await page.click('.login-submit');
await page.waitForTimeout(5000);
expect(await page.url()).toContain('/dashboard');

GOOD

// Stable and user-centric
const submitBtn = page.getByRole('button', { name: /log in/i });
await submitBtn.click();
await expect(page).toHaveURL(/\/dashboard/);
await expect(page.getByText(/welcome back/i)).toBeVisible();

Flakiness Prevention

| Risk | Solution |

| --- | --- |

| Animation lag | Disable CSS animations in the test environment |

| Third-party scripts | Block or stub chat widgets, ads, and telemetry |

| Race conditions | Assert state changes (e.g. "button is hidden") before next step |

Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.