DEV Community

Discussion on: Intercepting Http Requests-- Using And Testing Angular's HttpClient

Collapse
 
rossler123 profile image
Markus Rossler

Our server api has some special behaviour, in some cases it replies with an http error instead of a http 200 response with a proper body. This is legacy code, but on purpose. Not to break anything we need to handle with that. Since these are rare cases i want to simulate that and reuse it for unit tests as well.

Thread Thread
 
alisaduncan profile image
Alisa

In a unit test you can simulate errors. Does something like this work for you?
github.com/alisaduncan/tutorial-an...