Request Mocking
Request mocking lets tests isolate the UI from the network, returning canned responses for specific endpoints so tests are deterministic and fast. See the mock-route and remove-mock-route step reference pages for the step-level API.
Common patterns
- Stub a slow endpoint so the test runs in a fraction of the time.
- Return error responses to exercise error-handling UI.
- Pin a date, price, or inventory value that would otherwise drift.
- Isolate the frontend from an unbuilt backend.
Mock judiciously
Every mock is a promise about what the real service does. If the service changes and the mock does not, the test lies. Keep mocks close to the endpoints they cover and audit them on a cadence.