Reputation: 447
Currently I am writing test cases in jasmine for my stand-alone angularJs app, I need to write test cases for $http requests also, I wrote the tests to match the response from $http request and $httpBackend request, but that is not enough, what else can I verify for a $http request other than response status. Can format of data returned be verified? and what other stuff can be checked in a test spec?
Thanks!!
Upvotes: 1
Views: 1115
Reputation: 716
Have a look at Spies: http://angular-tips.com/blog/2014/03/introduction-to-unit-test-spies/
Spy on a service method call using jasmine Spies
You can do anything with a request. You can fake all responses (success, error), fire backend requests, which are faked to local json-files and so on.
Read more about jasmine / karma testing | jasmine / karma fake backend.
Upvotes: 1