How do I mock $http in AngularJS service Jasmine test?

后端 未结 1 1942
北荒
北荒 2020-12-10 05:50

I am trying to test an AngularJS service carService, but the $httpBackend does not seem to work.

//carService
angular.module(\'serv         


        
相关标签:
1条回答
  • 2020-12-10 06:35

    Try this:

    expect(response.data.length).toEqual(3);
    

    The response object returned by a $http request has the response data within the data property (docs).

    0 讨论(0)
提交回复
热议问题