BoilerPrompt
Cursor

Cursor prompt to write end-to-end tests

End-to-end coverage for the flows that actually break, written against stable test ids instead of brittle text selectors. In Cursor the agent proposes the flow list first, adds missing data-testid attributes as reviewable diffs, then runs the Playwright suite in your terminal and pastes the results, so you see green before you accept.

Last updated

Prompt
Write end-to-end tests for the critical paths of this app using Playwright. First read the routing and the auth flow, then propose the flows before writing any code. I expect signup, login, the primary create flow for {{resource}}, and logout at minimum. Put specs in e2e/, one file per flow, using data-testid selectors, and add those attributes to components where stable selectors are missing, never select on text or CSS classes. Seed and clean test data through the app's own API in beforeEach, not direct database writes. Each spec must pass headless and leave no residue rows. Add a fixture for an authenticated context so login runs once, not per test. Run the whole suite from the integrated terminal, paste the summary output, and list every component you touched to add test ids so I can check nothing user-visible changed.

Customize it

Runs in your browser. Nothing you type here is sent anywhere.

Your customized prompt
Write end-to-end tests for the critical paths of this app using Playwright. First read the routing and the auth flow, then propose the flows before writing any code. I expect signup, login, the primary create flow for users, and logout at minimum. Put specs in e2e/, one file per flow, using data-testid selectors, and add those attributes to components where stable selectors are missing, never select on text or CSS classes. Seed and clean test data through the app's own API in beforeEach, not direct database writes. Each spec must pass headless and leave no residue rows. Add a fixture for an authenticated context so login runs once, not per test. Run the whole suite from the integrated terminal, paste the summary output, and list every component you touched to add test ids so I can check nothing user-visible changed.

Same task in other tools

Questions about this prompt

Why make the agent propose flows before writing specs?

Because a wrong flow assumption wastes an entire generation. Reviewing a five-line flow list takes seconds, and correcting it before any code exists is far cheaper than rejecting spec files one at a time in the diff view.

The tests need the app running. Who starts it?

Use Playwright's webServer option so the suite boots your dev server itself and tears it down after. Tell the agent your start command and port, otherwise it may guess a stale script name out of package.json.

The suite passes locally but flakes headless. What is the usual fix?

Hard-coded waits. Ban explicit timeouts, rely on locator auto-waiting and expect polling instead, and have the agent enable trace on first retry so a failing headless run leaves a trace file you can open and step through.

Related prompts