I use ngMock module to mock a several requests like so:
$httpBackend.whenGET("/accounts").respond([obj]);
However, it seems that loading the module expects you to mock ALL requests. So if I do any other request other than those I mocked, I get "Unexpected request" error.
How can I configure it so that it ONLY intercepts requests that I mock explicitly, and passes everything else through?
You can use a regex and the passThrough() function built into $httpBackend.
beforeEach(inject(function($httpBackend){
$httpBackend.whenGET("/accounts").respond([obj]);
//Pass everything else through
$httpBackend.whenGET(/^\w+.*/).passThrough();
}));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With