Playwright

Modify a response in flight

Hard120 pts
  • route.fetch
  • In-flight Modification
  • Mocking
Practice app · Gear Shop

A product grid loaded from a real API with search, filters, infinite scroll and a checkout that calls a payments API.

Test URL
/lab/playwright-modify-a-response-in-flight

Your starter code already declares TEST_URL — never hardcode a host.

Objective

Fetch the real server response, modify properties in flight, and pass it back to the client.

Your Task

  1. 1Set up route interception for the products API endpoint ('**/api/practice/products*').
  2. 2Fetch the real server response using route fetch.
  3. 3Modify the response data by prefixing product names with '[PROMO]'.
  4. 4Fulfill the route with the modified JSON payload.
  5. 5Navigate to the practice catalog at TEST_URL and assert that a modified product title containing '[PROMO]' is visible in the catalog.

Validation Checks

  • Intercepts products API via page.route
  • Fetches real server response via route.fetch()
  • Fulfills route with modified [PROMO] product names
  • Practice catalog is loaded at TEST_URL
  • Product containing '[PROMO]' is verified visible
  • At least 1 assertion passes

Playwright · Playwright Practice Track · Network & mocking