0
我正在使用Karma在角度指令中测试函数。该函数执行正常,但其中的http.get
请求似乎被忽略,其他人抛出unexpected get
错误。Karma忽略角度http获取请求
beforeEach(inject(function($injector, $compile, $rootScope){
$gCompile = $compile;
$gScope = $rootScope;
$httpBackend = $injector.get('$httpBackend');
$gHttp = $httpBackend;
}));
it("Should login to the UI", function() {
//Compile directive
var element = angular.element('<my-app></my-app>');
$gCompile(element)($gScope);
//Reference it's local scope
var dirScope = element.scope();
$gScope.$digest();
dirScope.login();
});
获取请求在登录功能。
谢谢,调用flush看起来已经做到了。 – user3310447