# Keep your E2E tests, let an agent carry them
Table of Contents
End-to-end tests have one job: walk your core business flows before a deploy and make sure nothing broke. Keep the suite small. Own the few journeys that bring in money and can’t break.
Verification got harder
Last month, I pushed over 6,000 commits to a production app. An agent wrote most of them.
When you write code yourself, you know what to click through afterwards. When an agent writes it, you lose that mental map. Two things started to hurt:
- Everything outside the key journeys. Not money-critical, so they don’t need dedicated E2E scripts, but someone still needs to check them.
- The key journeys themselves. Every time a test went red, I had to dig in to see if it was a real bug or a flake.
So I wrapped my E2E suite in an agent. The tests still run as plain scripts. Around them, the agent explores the rest of the app and triages failures when a core test breaks.
The scan that started it
I gave eight agents a persona each: a solo user, an owner with colleagues, an employee doing payroll, a parent on a phone. Each got a real browser, seeded test data, and one rule: use the app like a person would.
They returned 55 findings. One of them:
An employee could open the accountant export and download every invoice in the account, including clients they never work with. The endpoint didn’t check permissions. Eleven of those 55 findings were old bugs that had come back undetected.
Unit tests didn’t catch this because the agent writes those in the same session as the feature code. They share the same blind spots. If the agent didn’t think to check permissions when building the endpoint, it won’t test for it either. I needed something independent to verify the work.
A goal describes the intent
Every flow starts as a goal: a short Markdown file defining who does what, and what counts as done.
# A session gets invoiced and paid
Sign in: owner
The owner saw a client today. She books that session afterwards, marks that he came,invoices it and sends the invoice to his mother. The mother pays by bank transfer,the owner records it, and the mother sees in the portal that it's paid.
## Limits- Start from the home screen. No search box, no assistant.
## Pass- The mother received the invoice mail.- The invoice is fully paid.- The mother sees it as paid in the portal.No selectors, no steps. I write the goal before any code exists. The agent checks my intent; it doesn’t define it.
The agent wraps the suite
On the first run, an agent walks the goal in a real browser and saves the path as a Playwright script. From then on, it’s an ordinary E2E test that runs without AI in about ten seconds.
These key journeys form my regression set:
- They run on every ship and before every deploy.
- A red result breaks the pipeline.
- The gate never auto-repairs anything. Fixes happen before shipping, where I can review them.
When a test fails, the agent inspects it before I do and sorts it into three buckets:
- A real bug. The test stays red and sends me a screenshot.
- A flake. Logged so I can track unreliable tests.
- The test lost its way. A renamed button or moved menu. The agent finds the new element, updates the script, and replays it.
If a repair just updates a renamed button, it gets logged. If it changes the actual user flow, like adding a step or detouring through another page, it flags a deviation. I review the diff and screenshots before approving.
Repairs have strict limits: the agent can change how a goal is reached, never the pass checks. If a goal can’t be reached, it’s a regression.
Every night, agents explore
Scripts handle regression. The night is for exploring.
At 02:00 , a cron job runs three steps:
- Focus. An agent reads recent commits and lists touched goals, changed screens, and potential conflicts.
- Walk. Persona agents walk those goals plus a rotating batch of others, covering the whole app weekly.
- Judge. A separate agent filters what the walkers found.
Each persona has a login, language, screen size, and habits, like a non-tech-savvy parent on a phone who gives up where a real user would. They also get a cheat sheet on the seeded data so they don’t report dummy data as bugs.
If the focus list spots a major new feature without a goal, the run drafts one. I tweak the intent and decide if it joins the regression set.
On one walk, a persona tried booking an appointment on a phone:
The regression script passes on every deploy. The persona still caught a bug: after picking a time, the form expands to 457 pixels on a 390-pixel screen, cutting a button in half. A script clicks straight through that. A real user gets stuck.
The agent judges, I decide
Walks generate plenty of false alarms. A judge agent reviews every finding with the codebase open:
- It checks past verdicts and open issues to avoid duplicates.
- It only dismisses a finding if seed data, a logged decision, or a business rule proves it’s intended.
- It only confirms a finding if it finds the exact line of code causing it.
What survives lands in my morning inbox with screenshots:
I make the final call. If I close an issue as “not planned” with a one-sentence explanation, the judge drops it on future runs.
In one night, the judge dismissed 41 false positives. Of the 24 real issues filed so far, 19 are fixed.
This setup costs 32 a night, mostly for the browser walks. It took some tuning: I moved the run to 02:00 to avoid usage limits, and pulled an API key after realising the test stack was hitting a live AI model instead of a local mock.
Where to start
Keep your E2E tests and keep owning them. Then:
- Write goals for the flows you care about.
- Let an agent turn them into scripts.
- Promote critical, stable ones to a regression set that gates your pipeline.
- Let personas explore the rest overnight.
Build the judge before automating the walks, or every noisy finding will land on your desk.
Grab the goal format, persona templates, and repair skill from shipping-with-an-agent/e2e, drop them into your repo, and adjust the commands.