Example result: Write an end-to-end test for a user journey
AI-generated example · E2E Test
Updated

Write an end-to-end test for a user journey

This prompt writes an end-to-end test for a full user journey, such as sign up to first project. It uses role and label selectors and real waits instead of sleeps, so the test does not break every time the design changes.

text-code-playwright-e2e-test — claude — 85 words

Act as a QA automation engineer using [TOOL, e.g. Playwright with TypeScript].

User journey to test: [STEPS, e.g. sign up, verify email, create first project]
App URL: [e.g. http://localhost:3000]
Useful selectors or page code: [PASTE OR DESCRIBE]

Write a reliable end-to-end test. Use role and label selectors, not CSS classes. Wait for real conditions, never fixed sleeps. Set up and clean up test data. Add clear step names so a failure is easy to read, and explain how to run it headed and in CI.

Selectors like getByRole and getByLabel survive design changes. CSS class selectors break often.

Get a better result

What you will get

A reliable end-to-end test that uses role and label selectors, waits on real conditions, sets up and cleans up test data, has clear step names, and comes with instructions to run it headed and in CI.

Common mistake

The test uses CSS classes and breaks after a redesign.

Fix: Keep the rule to use roles, labels and visible text. Paste the page’s markup so the AI can pick accurate ones.

Also watch for
  • It passes locally and fails in CI. Ask for no fixed waits, a stable test account and a fresh database state for each run, and note the CI browser and its settings.
  • The test data stays behind and breaks the next run. Ask for a setup and a cleanup step, using a unique email or name for each run.
Try a variation: add a failure screenshot

Ask for “a screenshot and a trace saved only when the test fails”. It makes CI failures much quicker to understand.

Still not right? Reply with this

Split the journey into three steps with clear names. After each, check one visible result, and keep the selectors based on roles and labels.

Guides that use this prompt

More chat & writing prompts

See all 465 →