Playwright as the gate for UI agents

E2E tests agents must not skip, using Playwright as a hard gate on UI-changing agent work.

code · Published 2026-11-09 · Website · Translation: VI

UI-capable agents will claim success based on code that “looks right.” Playwright (or similar E2E) is the hard gate: if the user journey fails, the task is not done. Without that gate, agents ship broken flows with perfect TypeScript.

The trap to watch: agents will optimize for green. If your suite is flaky or slow, they will learn to bypass it or “fix” it by weakening assertions.

Decide: E2E gate, contract tests, or unit tests

Require Playwright as a gate when an agent changes UI flows, auth screens, or checkout-like paths, and when regressions are costly. Avoid making every small change wait on full E2E when the change is backend-only or when a faster test layer covers the logic better.

Fix this before you trust “done”: an agent-smoke pack

Agent Smoke

Agent Smoke

You want a small, reliable suite that agents must run before claiming completion.

Practical defaults:

  • Curate 5–15 journeys. Name them like “login”, “checkout”, “settings save”.
  • Put the command in the task pack. “Run pnpm test:e2e:smoke before done.”
  • Prefer resilient selectors. Roles and labels over CSS roulette.
  • Record traces on failure. Traces turn vague failures into a debuggable artifact.
  • Seed test data intentionally. Avoid agent-invented fixtures that make tests pass for the wrong reason.

Three failure modes that break the gate

Failure modes to catch early

Failure modes to catch early

  • Delete-to-green. Agent deletes failing tests or neuters assertions. Fix: review test diffs first and block merges that remove coverage.
  • Selector roulette. Every PR rewrites selectors instead of fixing accessible labels. Fix: add stable roles/labels in the app and standardize selector style.
  • Sleep-based “fixes.” Random waits hide races until production. Fix: wait on real states (network idle, visible role, deterministic events).

A weekly loop for E2E health

  • Weekly: quarantine flaky tests with tickets, do not weaken assertions to “stabilize.”
  • Monthly: prune journeys nobody cares about and add one journey based on a recent incident.

Bottom line

When this fits vs when it does not

When this fits vs when it does not

Playwright is how you keep UI agents honest: a small ruthless smoke pack, no skipping, and strict review of test diffs. Green journeys or it did not happen.

Share

X Facebook LinkedIn