Mock a payment failure
Hard120 pts
- Error Simulation
- Negative Testing
- route.fulfill
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
Simulate an error or decline from the checkout payment gateway and verify UI error handling.
Your Task
- 1Set up route interception for the payment endpoint ('**/api/practice/checkout' or '**/api/practice/payments') returning an HTTP 500 status with an error payload containing message 'Card declined'.
- 2Navigate to the practice catalog at TEST_URL.
- 3Trigger the checkout action by clicking the checkout button (#checkout).
- 4Assert that an error message or alert containing 'Card declined' is visible.
Validation Checks
- Payment endpoint is routed to status 500 with 'Card declined'
- Practice catalog is loaded at TEST_URL
- Checkout action (#checkout) is triggered
- Error message (#payment-error or alert) is verified containing 'Card declined'
- At least 1 assertion passes
Playwright · QA Automation Practice Track · Network & mocking