mercredi 1 juillet 2015

$httpBackend with AngularJS/Jasmine - why mock a response?

The AngularJS tutorials say that when using $httpBackend a response should be mocked. What I'm unsure about is why would I want to mock a request to an API when I could just use $http and make the request and retrieve the 'real' data? I can then run the test on the actual response, this allows to check if data response from the API has changed (for what ever reason). However, if I was mocking the response and the API data changes, then my mock response will be different to the actual response. Therefore making the tests incorrect.

Aucun commentaire:

Enregistrer un commentaire