DEV Community

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

alisaduncan profile image
Alisa Author

Hi there! Sorry it took me so long to respond; I didn't see this comment until now. 😬

I hear what you're saying, it is a lot of steps and I've made the mistake of not calling .flush() when testing myself. However, I do like that Angular's HttpClientTestingModule allows me to verify expected number of times a call is made without using a Jasmine spy. I also like that I can verify the HTTP method used in the call, headers, etc separately from verifying the subscribe portion.

For more complicated service calls (where there's retries, different HTTP methods, or custom headers), being able to assert separately starts making more sense.

For straightforward requests like what I have in this post, having an all-in-one solution like what you propose is a great way to go and definitely helps to make things easier. 🙂

Thank you for taking the time to read and comment! These kinds of discussions are great!