Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk5 min

Playwright Backend Failures: Build UI Tests That Verify Recovery

Intercept a backend request in Playwright, choose a realistic failure mode, and verify both the error UI and recovery path.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To test how a Playwright UI handles a backend failure, intercept the relevant request before it is sent and decide exactly how it fails: return a controlled HTTP error, abort the request, or take the browser offline. Then assert the visible error state. If the product is supposed to recover, remove or replace the failure and use the same retry path a user would before asserting that content returns.

Choose a failure that matches the user scenario

Playwright can track, modify, and handle browser requests, including fetch and XHR requests, using its network-routing APIs. A controlled HTTP response and a failed network request are different conditions, so choose deliberately rather than treating every failure as a generic “server error.”

As an Amazon Associate I earn from qualifying purchases.

Scenario Playwright mechanism What the page receives
Backend returns an application-level error route.fulfill() A response with the status and body you choose, such as a 500 or 503.
Request fails before an HTTP response arrives route.abort() A failed request, not an HTTP response body.
Connectivity is broadly unavailable Set the browser offline A broad network failure affecting requests, useful for testing offline behavior.
Repeat requests from recorded traffic HAR replay Recorded responses, matched strictly by URL and HTTP method.
Use the real API response but alter what the page sees route.fetch(), then route.fulfill() The live response with controlled changes.
Feature depends on a real-time socket WebSocket routing or mocking Controlled socket behavior rather than an HTTP API response.

These mechanisms are documented in Playwright’s network guide, API mocking guide, and network-mocking guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install the route before the request happens

A route only controls requests made after its handler is registered. Add it before navigation if the page requests data on load, or before the user action that triggers the request. Use page.route() for one page; use browserContext.route() when the handler should apply across a context. If both match, page-level routing takes precedence over context-level routing.

#1 Best Overall
Sale
Acer Predator Helios Neo 18 AI Gaming Laptop | Intel Core Ultra 9 Processor 275HX | NVIDIA GeForce RTX 5070 Ti | 18" WQXGA 240Hz G-SYNC | 32GB DDR5 | 2TB Gen 4 SSD | Killer Wi-Fi 6E | PHN18-72-9474
  • Desktop-Level Performance, Anywhere: Get legendary gaming performance with the Intel Core Ultra 9 275HX processor, delivering ultra-smooth gameplay and future-ready AI (Up to 13 NPU TOPS). Offload tasks like background removal and audio optimization to the NPU for seamless streaming and gaming, while Intel Application Optimization enhances performance on classic titles.
  • Game-Changing Realism: Powered by NVIDIA Blackwell architecture, GeForce RTX 5070 Ti Laptop GPU unlocks the game changing realism of full ray tracing. Equipped with a massive level of 992 AI TOPS horsepower, the RTX 50 Series enables new experiences and next-level graphics fidelity. Experience cinematic quality visuals at unprecedented speed with fourth-gen RT Cores and breakthrough neural rendering technologies accelerated with fifth-gen Tensor Cores.
  • Supreme Speed. Superior Visuals. Powered by AI: DLSS is a revolutionary suite of neural rendering technologies that uses AI to boost FPS, reduce latency, and improve image quality. DLSS 4 brings a new Multi Frame Generation and enhanced Ray Reconstruction and Super Resolution, powered by GeForce RTX 50 Series GPUs and fifth-generation Tensor Cores.
  • The Ultimate in Ray Tracing and AI: NVIDIA RTX is the most advanced platform for full ray tracing and neural rendering technologies that are revolutionizing the ways we play and create. Over 700 games and applications use RTX to deliver realistic graphics and incredibly fast performance with cutting-edge AI features like DLSS Multi Frame Generation.
  • Immersive Depth and Detail: At 18 inches with a 16:10 aspect ratio, the pristine WQXGA screen offering vibrant colors with up to 100% DCI-P3 operates at a fast 240Hz refresh and 3ms overdrive response time. Alongside the suite of features from NVIDIA G-SYNC and NVIDIA Advanced Optimus, you're guaranteed that whatever's on-screen is a distinct viewing delight.

Match the narrowest URL pattern that represents the dependency under test. Playwright glob patterns match the entire URL, so use a regular expression or predicate if that expresses the intended endpoint more clearly. Every matching handler must resolve the request by continuing, fulfilling, or aborting it.

Example: return a controlled server error

import { test, expect } from '@playwright/test';

test('shows an error when the orders API fails', async ({ page }) => {
  await page.route('**/api/orders', route =>
    route.fulfill({
      status: 503,
      contentType: 'application/json',
      body: JSON.stringify({ message: 'Service unavailable' }),
    })
  );

  await page.goto('/orders');

  await expect(page.getByRole('alert')).toContainText('could not load');
  await expect(page.getByRole('button', { name: 'Retry' })).toBeVisible();
});

This example verifies an HTTP-level failure and the user-facing result. Adjust the endpoint and assertions to match the application; the test should check the actual error copy, empty state, degraded feature, or retry control that matters to users.

Example: simulate a failed request

await page.route('**/api/orders', route => route.abort());
await page.goto('/orders');
await expect(page.getByRole('alert')).toBeVisible();

Aborting tests how the UI handles a request that fails at the network layer. Use offline mode instead when the requirement is a broader loss of connectivity rather than a single endpoint failing. Playwright demonstrates offline network state in its network-mocking documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Assert the state the user experiences

Use web-first assertions such as toBeVisible() or toContainText() for asynchronous UI changes. These assertions retry until the condition is met or the assertion timeout expires. Playwright documents a five-second default assertion timeout, but project configuration and per-assertion settings can change actual timing.

Rank #2
Lenovo Legion 5 15IRX10 15.1" WQXGA OLED, Gaming Laptop, Intel Core i9 14th Gen 14900HX 1.6GHz; NVIDIA GeForce RTX 5070 8GB GDDR7; 32GB DDR5 RAM; 1TB NVMe M.2 SSD; Gigabit LAN, 2x2 WiFi 7
  • Intel Core i9 14th Gen 14900HX 1.6GHz Processor, NVIDIA GeForce RTX 5070 8GB GDDR7, 32GB DDR5-5600 RAM
  • 1TB PCIe Gen4 x4 NVMe M.2 SSD
  • 15.1" WQXGA OLED Glossy Display
  • Gigabit LAN, 2x2 WiFi 7 (802.11be), Bluetooth 5.4
  • 4.19 lbs. (1.90 kg),Windows 11 Home

A fixed sleep only waits for a duration; it does not establish that the intended state appeared. Assert the result that represents the requirement: an error message, a retry action, an empty state, or a feature-specific degraded state. The Playwright assertions reference explains web-first assertion behavior.

Test recovery through the user’s retry path

A failure-state test proves only that the UI responds to failure. When recovery is part of the requirement, also test that the page returns to its normal state after the cause is removed and the user retries.

test('recovers when retry succeeds', async ({ page }) => {
  let shouldFail = true;

  await page.route('**/api/orders', route => {
    if (shouldFail) {
      return route.fulfill({
        status: 503,
        contentType: 'application/json',
        body: JSON.stringify({ message: 'Service unavailable' }),
      });
    }

    return route.fulfill({
      status: 200,
      contentType: 'application/json',
      body: JSON.stringify([{ id: 'order-1', name: 'Recent order' }]),
    });
  });

  await page.goto('/orders');
  await expect(page.getByRole('alert')).toBeVisible();

  shouldFail = false;
  await page.getByRole('button', { name: 'Retry' }).click();

  await expect(page.getByText('Recent order')).toBeVisible();
});

The important part is the sequence: induce the failure, verify the error state, change the route’s behavior, activate the application’s retry control, and verify successful content. Playwright’s network-mocking workflow and CLI network-routing guide demonstrate this failure-and-recovery pattern.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Pick fixtures and routing scope for repeatability

Static responses for known cases

Use route.fulfill() when the test needs a predictable status and body. It keeps the API out of the test path unless the handler first fetches a live response, making the failure fixture easier to control.

Rank #3
Sale
Light Gaming Laptop, ΑΜD Ryzen 5700U (Up to 4.3GHz), 16GB RAM 512GB SSD
  • [Top Performance Processors] KAIGERR Light gaming laptop R7-5700U by ΑΜD ZEN 3 architecture, matched with 16MB of L3 cache, built by TSMC 7nm process with 8 cores & 16 threads (turbo up to 4.3GHz). KAIGERR office light gaming laptops makes it easy to qualify for your PC work and PC games which have amazing loading and processing power for a smoother PC used experience
  • [Huge Capacity Storage] KAIGERR laptop comes with 16GB SODIMM DDR4 RAM, advantages of large operating memory capacity both can reduce read latency of memory data and improve CPU utilization. KAIGERR laptop computer configured with an M.2 2280 NVMe 512GB SSD which offers fast startup and loading of applications, as well as a large amount of storage space for your various files
  • [Brilliant Display & Integrated Graphics] KAIGERR Light gaming laptop features an innovative thin-bezel display that provides more usable onscreen space for immersive FHD viewing. KAIGERR laptop integrates with ΑΜD Radeon Graphics and delivers strong graphics processing like a rich level of image detail making it possible to play computer games or edit pictures with a great experience on this laptop
  • [Rich Interfaces & Wireless Connectivity] KAIGERR traditional laptop offers a variety of connectivity options, including HDMI, Type-C, 3.5mm TRRS Jack, Memory Card Slot and USB3.2 ports. You can easily connect to various devices and peripherals to expand your capabilities. Mini laptop computers equipped with WiFi6 & Bluetooth 5.2 which offer strong wireless signal, fast wireless connections, and reliable transmission speed
  • [Portable Design & Durable] KAIGERR laptop compact design makes it easy to carry with you wherever you go. Also, you can enjoy the benefits of a powerful computer without the bulk of a traditional desktop. KAIGERR laptop computers are built with high-quality components and designed to handle heavy workloads and deliver consistent performance and longevity. If you encounter any problems, please contact us and we will help you solve the problem within 12 hours

HAR replay for recorded traffic

HAR replay can reuse recorded request and response data. Its matching is strict about URL and HTTP method, so ensure the recording corresponds to the request the test actually makes. See Playwright’s API mocking guide.

Live response with a controlled patch

Use route.fetch() and then route.fulfill() when the test needs to call the real backend but alter the response seen by the page. This retains a live dependency, so it is less isolated than a static fixture.

Page or context routing

Page routing keeps a handler focused on one page. Context routing covers pages in that browser context and is useful when the dependency should be intercepted more broadly. Playwright’s BrowserContext reference documents context routing and its behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep routing tests isolated and diagnose missed requests

Playwright creates isolated browser contexts for tests, separating browser state. Keep each test’s route setup and expected result scoped to the scenario so one failure fixture does not unintentionally affect another. The browser-context guide explains test isolation.

Rank #4
KAIGERR Gaming Laptop, 24GB DDR5 512GB NVMe SSD Laptop Computer with AMD Ryzen 7 H255(8C/16T, Up to 4.9GHz), 16.0 inch Windows 11 Laptop, Radeon RX Vega 8 Graphics,WiFi 6, Backlit KB
  • 【ENGINEERED FOR SPEED】The KAIGERR 2026 RX16 laptop is equipped with the powerful AMD Ryzen 7 H255 processor (8C/16T, up to 4.9GHz), delivering superior performance and responsiveness. This upgraded hardware ensures a smooth experience, fast loading times, and high-quality visuals. It provides an immersive, lag-free experience. Its performance is far moere than 30% better than AMD R7 5700U/5800U/5825U/6600HX/7735HS.
  • 【Advanced Dual-Fan Cooling】KAIGERR’s dual-fan system expels heat faster than standard designs, drastically reducing thermal buildup during intense gaming or work. Optimized airflow keeps components cool, prevents throttling, and maintains smooth, sustained performance—all while staying quiet. Stay cool, play longer.
  • 【INSPIRE YOUR POSSIBILITIES】 The laptop on sale comes with 16GB DDR5 memory and a 512GB M.2 NVMe SSD for faster response times and ample storage. Dual-channel DDR5 memory supports upgrades to 64GB (2x32GB), and NVMe/NGFF SSD can be upgraded to 4TB, providing plenty of space for all your favorite videos/files.
  • 【Vivid 16.0" IPS Display】Featuring a wide color gamut and high refresh rate, the 16.1" IPS screen delivers smoother motion, richer colors, and exceptional detail—surpassing standard displays in both accuracy and immersion. Whether gaming, streaming, or creating, every frame appears lifelike and dynamic for a truly engaging visual experience.
  • 【KAIGERR: Quality Laptops, Exceptional Support.】Enjoy peace of mind with unlimited technical support and 12 months of repair for all customers, with our team always ready to help. If you have any questions or concerns, feel free to reach out to us—we’re here to help.

If a request does not reach a native page or context route handler, check whether a service worker is handling it. Playwright documents that its native routing does not intercept requests handled by service workers; when interception is required, the routing reference recommends blocking service workers. Routing also disables the HTTP cache, which can make routed traffic differ from ordinary browser traffic.

Separate application resilience from test retries

A retrying assertion waits for a UI condition; a test-runner retry reruns a failed test. Neither, on its own, proves that the application can recover from a backend failure. Recovery requires an explicit test of the application’s retry or fallback behavior.

For intermittent failures, capture a trace to inspect what happened. Playwright’s test configuration documentation shows trace: 'on-first-retry' as an available setting. Avoid using transport retry settings as a substitute for deliberate failure scenarios: the Route reference says maxRetries, added in v1.46, retries only ECONNRESET, not HTTP response codes. The current reference also documents newer options, so check the API documentation for the installed Playwright version before using version-sensitive settings.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.