← Index

How I Work

Letting AI Write My Tests - Full Stack

TL;DR - I let an AI agent write my tests. Playwright e2e on the frontend, pytest on the backend. It found edge cases I never would have thought of, and my code is the most stable it has ever been, with none of the manual clicking.

The problem

I've written frontend for years. Stability was always the hard part.

  • You can't manually click through every flow on every change.
  • The bugs that reach production are almost always the edge cases and weird user paths you didn't think to test.

What I did

I tried AI-written e2e testing about six months ago with an older model. Honestly? It was mediocre. I tried it again recently with the current generation (Opus / Fable) and it was a completely different league.

The workflow that worked.

  1. I write a few test scenarios myself - the obvious happy paths.
  2. I let the agent expand from there, driving a real browser through the Playwright MCP.
  3. It generates the cases I'd miss - edge cases, unusual flows, the states that actually break in production.
  4. I keep the suite documented and readable so it stays maintainable as it grows.
My happy pathsAgent expandsEdge cases caughtShip

What the agent writes looks like this.

ts
test("guest can submit an application", async ({ page }) => {
  await page.goto("/apply");
  await page.fill("[name=email]", "guest@example.com");
  await page.click("text=Submit");
  await expect(page.locator(".confirmation")).toBeVisible();
});

The backend gets the same treatment

Same loop on the API side.

  • The agent writes pytest tests against the running backend - real Flask, real Postgres, on localhost.
  • It hammers the endpoints - validation, auth, permission boundaries, the wrong-role and bad-input cases.
py
def test_rejected_user_cannot_check_in(client, rejected_user):
    res = client.post(f"/applications/{rejected_user.id}/check-in")
    assert res.status_code == 403

Frontend clicks + backend calls. The whole stack is guarded.

The result

  • The most stable code I've shipped - regressions get caught before they reach users.
  • No more manual click-testing. The agent writes the tests, the tests catch the bugs, I ship with confidence.
  • It's now a default on every project, not a one-off experiment.

The lesson

AI-written e2e testing flips testing from a chore you skip under deadline into a stability multiplier you get almost for free. The key unlock is the Playwright MCP - giving the agent a real browser to test against, not just code to reason about.

Stack - Playwright, Playwright MCP, pytest, Claude / Fable.

← Back to all