I am trying to test the HTTP calls and referring to the following page to write unit tests: https://angular-2-training-book.rangle.io/handout/testing/services/mockbackend.html
But when I looked on the Angular website it looks like the MockBackend
class is deprecated: https://angular.io/api/http/testing/MockBackend
The same website has a different way to test HTTP calls: https://angular-2-training-book.rangle.io/handout/testing/services/alt-http-mocking.html
I also came across an interesting article below (as I am trying to test login so making a POST call): http://jasonwatmore.com/post/2016/11/24/angular-2-mockbackend-example-for-backendless-development
So I wanted to know which is the best or latest way to test HTTP calls? I am a bit confused to whether use MockBackend
or use the spyOn
mocking strategy.