Skip to content

Playwright

Playwright drives a real browser, which is what the journey tests need: the composition, the navigation, the focus behaviour and the timing are the subject of the test, and none of them exist outside a browser.

The single practice that decides whether this level is worth its cost.

// What a person looks for.
page.getByRole('button', { name: 'Apply voucher' });
page.getByLabel('Voucher code');
page.getByRole('alert');
// What a test framework can see, and a user cannot.
page.locator('[data-testid="voucher-btn"]');
page.locator('.form__field > div:nth-child(2) > button');

The first group has a property the second lacks: if the selector breaks, something a real user depends on has changed. A button that lost its accessible name breaks the first and passes the second — and it is broken for every screen reader user in production.

It also means the journey test doubles as a continuous check that the interface remains navigable by role and name, which is most of what accessibility means mechanically.

Every fixed wait is a race that will be lost on a slower machine, and flakiness is what kills this level — not by deletion, but by tests being skipped one at a time, each with a good reason.

Playwright’s assertions retry by default, which is the mechanism to lean on: assert the end state and let it converge, rather than sleeping and hoping.

Run the accessibility scan in the same pass

Section titled “Run the accessibility scan in the same pass”

The page is already loaded, in a real browser, at a meaningful state. Scanning there costs almost nothing and catches the class of violation that only exists in composition — heading order across a whole page, landmark nesting, focus after a route change, a modal opened from a control that focus never returns to.

Component-level scans cannot see any of those, by construction.

Component behaviour. If it can be asserted against a story, it should be: same coverage, a fraction of the runtime, and a failure that names a component instead of a step.

Third parties. Payment providers, map tiles, analytics. Slow, rate-limited, non-deterministic, and not what the test is about. Stub at the network boundary.

Visual comparison. Playwright can take screenshots, which makes it tempting to grow a page-snapshot suite here. See visual regression for why page-level snapshots are the version of that idea which stops working first.