Stub a search API response
Medium70 pts
- page.route
- route.fulfill
- Mocking API
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.
Your starter code already declares TEST_URL — never hardcode a host.
Objective
Intercept outgoing search requests and return custom mock JSON using route interception.
Your Task
- 1Set up route interception for the products search API endpoint ('**/api/practice/products*') using route mocking.
- 2Fulfill the route with mock JSON data containing a test product (such as 'Mock Super Phone' with price 999).
- 3Navigate to the practice catalog at TEST_URL.
- 4Search for 'Mock' using the search box (#search-box) and submit the search.
- 5Assert that the mocked product ('Mock Super Phone') appears and is visible on the page.
Validation Checks
- Routes '**/api/practice/products*' and fulfills with mock JSON
- Practice catalog is loaded at TEST_URL
- Search query 'Mock' is submitted via #search-box
- Mock product 'Mock Super Phone' is verified visible in the UI
- At least 1 assertion passes
Playwright · QA Automation Practice Track · Network & mocking