Your unit tests are green, you deploy, and the first real user hits Sign up and nothing happens: the button is hidden behind a modal, or the form posts to an endpoint that moved last week. Every signup that breaks is someone who may not come back, and you find out from silence, not from an error log. One small browser test that clicks the flow like a person would catches this before the deploy, not after.
That test is cheap to get now: describe the flow to your coding agent in plain English, have it write a Playwright end-to-end test for the one or two flows that make you money, and make the agent prove the test actually fails when the flow breaks. Playwright is open source and free (playwright.dev), and the agent writes the selectors, so you don't have to.
The flow that pays deserves a test that clicks like a user
Unit tests check functions in isolation. They cannot see a button buried under a cookie banner, a form whose submit handler silently died, or a checkout that charges the card and never shows the receipt. Those are all things that happen to real apps, and none of them fail a unit test.
Signup and checkout are the two flows where a broken screen costs you money directly. So they get the treatment a human gets: open the page, fill the fields, press the button, and demand something visible on screen at the end. Anything less is testing your code, not your product.
Write the user story first, then hand it to the agent
The test is only as sharp as the story you give the agent. Write it before asking for code: the steps a user takes, and what success looks like on screen. "Signup works" produces a useless test. "The URL changes to /welcome and the page shows 'Check your inbox to confirm'" produces one that can fail.
Here is a prompt you can paste into your agent today:
Write a Playwright end-to-end test for our signup flow.
User story:
- A new visitor opens /signup
- They type their name into the field labeled "Name"
- They type their email into the field labeled "Email"
- They type a password into the field labeled "Password"
- They check the checkbox labeled "I agree to the terms"
- They click the button named "Create account"
Success looks like:
- The URL changes to /welcome
- The page shows the text "Check your inbox to confirm"
Rules:
- Locate elements with getByRole and getByLabel, never CSS classes
- Use web-first assertions like expect(...).toBeVisible()
- No sleeps and no waitForTimeout
- Use a throwaway account: [email protected], never a real email
- The test must fail if the button never appears or the
confirmation text never shows
Give me the test file, then run it and paste the output.
If your fields or labels differ, change the story, not the rules. The story is the source of truth; the agent translates it. You need an agent that can run the test and read the output, not one that only writes code into a chat window; if you don't have one set up, you can try the zcode agent harness free.
Locators that survive a redesign, assertions that don't sleep
The two habits that decide whether your test dies next month are locators and assertions.
Locate by role and label: getByRole('button', { name: 'Create account' }) finds the button by what it is and what it says, and getByLabel('Email') finds the input by its label. The Playwright docs recommend prioritizing these user-facing attributes because they match how users and assistive technology see the page (playwright.dev/docs/locators). When you redesign the page and the button changes color, size, and position, the test still finds it, because it is still a button that says "Create account". A test built on .css-class-v7-final dies the day someone renames a class.
Then assert web-first: expect(page.getByText('Check your inbox to confirm')).toBeVisible() rechecks the page over and over until the text shows up or the assertion times out, five seconds by default (playwright.dev/docs/test-assertions). That is the whole anti-flake trick. A waitForTimeout(3000) sleep is slow when the page is fast and broken when the page is slow; a retrying assertion is neither.
Make the agent break the flow on purpose
A test you have never seen fail proves nothing. It might pass no matter what the app does, which is worse than no test, because it gives you false confidence every single run.
So sabotage the app. Paste this checklist for the agent:
1. Change the submit button's name to "Submit" and run the
test. It must fail, at the getByRole('button', { name:
'Create account' }) step.
2. Change the success text to "Thanks!" and run again. It
must fail on the assertion.
3. Restore both changes exactly as they were. Run once more.
It must pass.
If step 1 or 2 comes back green, the test is not checking what you think it is, and you fix it before you trust it. The failure is the proof. After step 3, run git diff and make sure the app code is exactly as it was before the sabotage; only the new test file should be left.
Test data that can't burn you
Never let a test touch real accounts, real cards, or real inboxes. Run against a local or staging environment, with a throwaway account like [email protected] or a user your test setup seeds into a test database.
If the flow charges money, use your payment provider's test mode keys in that environment, which is exactly what they exist for. Check which URL the test points at before you run it the first time, and never at production. The one-time cost of setting up a seeded test user is nothing next to emailing a real customer a fake order.
One command, every change
npx playwright test runs your tests headless by default: no browser window opens, results land in the terminal (playwright.dev/docs/running-tests). That single command is what you run after every change, and what your agent runs before it tells you a feature is done.
Then put it in CI so it stops depending on memory. The Playwright docs walk through setting it up on a CI service (playwright.dev/docs/ci-intro), and the same pattern works on any runner. From then on, a broken signup fails the build before it can reach a user.
Your agent will run this command many times a day, every change and every fix. If you are picking a plan for that kind of steady use, there's 10% off GLM coding plans.
The checklist
- One user story per money flow, with the success state written down
- Locators by role and label, no CSS classes
- Web-first assertions, no sleeps
- The test was seen failing twice on purpose, then passing
- Throwaway accounts and test-mode payments only, never production
npx playwright testruns on every change and in CI
Start with one test on the flow that makes you money. Everything else can wait. For the layer underneath, see Test first, then let the agent code and prove it. There's more on our blog about working with coding agents day to day.
If this saved your next launch from a silent signup bug, a small tip on the post keeps these guides coming.






Latest comments
0