我运行e2e测试的角度应用程序没有手动执行ngApp指令和bootstraps。在这种情况下,是否无法通过量角器插入模拟模块?
//load angular mocks as a string here
var angularMocks = require('./angularMocks.module.js').mock;
browser.addMockModule("ngMockE2E", angularMocks );
browser.addMockModule('httpBackendMock', function httpBackendMock() {
console.log('inside httpBackendMock');
angular.module("httpBackendMock", ['ngMockE2E'])
.run(['$httpBackend', function ($httpBackend) {
console.log("Inside Run");
$httpBackend.whenGET(/.*employees.*/).respond(404, '');
$httpBackend.whenGET(/.*/).passThrough();
$httpBackend.whenPOST(/.*/).passThrough();
$httpBackend.whenPUT(/.*/).passThrough();
}]);
});
browser.get(url);
这会在浏览器控制台中记录'httpBackendMock',但不会记录'Inside Run',表示API调用从未被截获。