0

Jasmine could use $httpBackend to make fake restful calls by using

$httpBackend.whenGet("https://www.test.com")
            .respond({....})

But can I make real data calls to the server I make?

Gabriel
  • 601
  • 1
  • 10
  • 26

1 Answers1

0

This is an angular question, not a jasmine one, $httpBackend is from angular.

In ngMock $httpBackend don't make a real call, but it can with ngMockE2E. To use both together, refer to

E2E mock $httpBackend doesn't actually passThrough for me

or

https://github.com/angular/angular.js/issues/1434

then you can use :

$httpBackend.whenGet("https://www.test.com").passThrough();

Community
  • 1
  • 1
Boris Charpentier
  • 3,515
  • 25
  • 28
  • But I got an error of Object doesn't support property or method 'passThrough' when I use passThrough in Jasmine. And it works fine with the respond. – Gabriel Jan 19 '15 at 18:28
  • You can check the doc here : https://code.angularjs.org/1.2.28/docs/api/ngMockE2E/service/$httpBackend#when – Boris Charpentier Jan 20 '15 at 10:04
  • Ho my bad just realise you need ngMockE2E, not just ngMock ! – Boris Charpentier Jan 20 '15 at 10:05
  • I tried ngMockE2E but it still didn't work. same issue here in angular github: https://github.com/angular/angular.js/issues/2512. I'm running $httpbackend in unit tests. I'm not sure whether this cause the problem. – Gabriel Jan 20 '15 at 19:20
  • Did you check the end of this thread : https://github.com/angular/angular.js/issues/1434 – Boris Charpentier Jan 20 '15 at 20:23