Claude Code prompt to write end-to-end tests
E2E suites written blind are flaky by design. This prompt makes Claude Code propose the flows first, then run the finished suite headless from your terminal, twice in a row, so ordering bugs and timing flakes show up before CI ever sees them. The boot-wait-run-teardown target it adds becomes your CI entry point.
Last updated
Write end-to-end tests for this app's critical paths using the E2E framework already in the repo, or Playwright if none exists. Start by reading the routes and listing the flows you plan to cover; wait for my confirmation before writing tests. Cover at minimum: signup or login, the primary create-and-save flow, and one destructive action with its confirmation dialog. Rules: no fixed sleeps, use web-first assertions or explicit waits; each test seeds its own data through the API or a fixture, never through another test; everything must pass in headless mode from the command line. Add an npm or make target that boots the app, waits for the health endpoint, runs the suite, and tears down. Run it twice back to back and report both results so we know the tests are not order-dependent or flaky on first sight.
Same task in other tools
Questions about this prompt
Why does the prompt pause for confirmation before any test is written?
The flow list is a product decision, and a wrong list wastes the whole generation pass. Reviewing five bullet points takes a minute and anchors everything the agent writes afterward to paths you actually care about.
Every flow in my app sits behind login. Do all tests repeat the signup steps?
No. Ask for a storage-state fixture: authenticate once through the API, save the session, and load it per test. The destructive-action test should still assert the confirmation dialog with a real click, since that is UI behavior.
The suite passes locally and fails in CI. Where do I look first?
Usually the app was not ready when the first test ran. The run target's health-endpoint wait covers most of it; for what remains, have Claude Code rerun the failing spec with tracing enabled and read the trace to see which wait fired early.