Network interception
Intercept matching browser requests: mock a response, block a third party, or let it through and read what came back.
- Routing Answer a request without a server
- Blocking Drop what you did not come to test
- Observing Wait for the response, not for a delay
Answer a request without a server
Match a URL pattern and fulfil it from the test. The scenario can exercise a browser state without depending on a live test backend for that response.
Mock an API response →$page->route('**/api/orders', function ($route) {
$route->fulfill([
'contentType' => 'application/json',
'body' => json_encode(['orders' => []]),
]);
});Drop what you did not come to test
Analytics, chat widgets, ad tags. Abort matching requests when a third party is outside the scenario and would only add external noise.
Block unwanted requests →Wait for the response, not for a delay
Requests and responses are events you can await and inspect: status, headers, body. Assert on the exchange the page actually made.
Wait for a network response →Move from the tour to working code.
Choose the explanation, recipe, or runnable example that matches what you need next.