skip to content

Network Interception

How a Playwright run takes over the request layer: matching routes, fulfilling or aborting them, replaying HAR files, and calling APIs directly to reach states no real backend will produce.

on this pageshow

explore

questions

page 2 of 2

In Playwright, when should a suite fully mock a WebSocket instead of routing it to the real server?

level: principalimportance: should knowfreq 28%

basics

~20 s

Mock fully when determinism, offline runs and speed matter more than fidelity, which covers the bulk of UI cases. Connect to the real server when the handshake is complex or integration itself is the point.

open as a page

When should a Playwright suite fulfil from fixtures instead of fetching and mutating the real API?

level: principalimportance: nice to knowfreq 24%

basics

~20 s

Fulfil from fixtures for everything that runs on every commit, because those tests must be fast, hermetic and deterministic. Reserve fetching and mutating the real response for a thin, separately scheduled layer whose job is noticing that the upstream contract has drifted.

open as a page

showing 31–32 of 32