Testing REST endpoints with fake HTTP statuses
Sometimes when developing a service that calls an external REST API or testing calling an endpoint from a front-end, you'll need to test what happens when that API returns different HTTP status codes. You can do this using tests, and mock/stub a 404
, 500
, etc. But often it's very helpful to see what happens when a specific response status is returned.
Or imagine your QA team needs to manually test what happens when a 500
is returned. For example, they need to confirm an error page shows if the app receives an error response. In that scenario you can't (purely) rely on stubbed automated tests.