1

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!!

Prabhjot Kaur
  • 427
  • 3
  • 6
  • 19

1 Answers1

1

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.

Community
  • 1
  • 1
Develobba
  • 716
  • 8
  • 22