ngMockE2E is causing every request mock the moment added to dependency

511 views Asked by At

I have

angular.module("myModule", [
 //Some dependency
 "ngMockE2E"
])

This is actually mocking template request and throwing error

Unexpected request: GET javascripts/custom/utils/templates/global_loader.html
No more request expected
    at $httpBackend (angular-mocks.js?e_a_v=5:1226)
    at sendReq (angular.js?e_a_v=5:10215)
    at $get.serverRequest (angular.js?e_a_v=5:9927)
    at processQueue (angular.js?e_a_v=5:14437)
    at angular.js?e_a_v=5:14453
    at Scope.$get.Scope.$eval (angular.js?e_a_v=5:15702)
    at Scope.$get.Scope.$digest (angular.js?e_a_v=5:15513)
    at Scope.$get.Scope.$apply (angular.js?e_a_v=5:15807)
    at bootstrapApply (angular.js?e_a_v=5:1628)
    at Object.invoke (angular.js?e_a_v=5:4426)

If I comment out ngMockE2E, it works fine. Any idea what I am doing wrong?

1

There are 1 answers

0
Phil On BEST ANSWER

ngMockE2E introduces $httpBackend so yes, all HTTP requests are mocked. To allow your templates to be loaded, add this to your module

.run(function($httpBackend) {
    // pass through template requests
    $httpBackend.whenGET(/\.html$/).passThrough();
});