单元测试$ scope。使用Jasmine 2.0的$ evalAsync函数

时间:2015-08-03 19:28:58

标签: javascript angularjs unit-testing jasmine karma-jasmine

我正在尝试对$ scope。$ evalAsync函数进行单元测试。这是我的代码:

$scope.$evalAsync(function(done) {
    //enable the popover plugin
    done();
    jQuery('[data-toggle="popover"]').popover();
    $scope.isKioskIdLoaded.state = true;
});

我很难理解如何在我的Jasmine测试中运行evalAsync。我正在尝试使用Jasmine 2.0中的done()函数。

1 个答案:

答案 0 :(得分:0)

您需要在Jasmine测试中添加$scope.$digest()。将evalasync函数添加到Angular的asyncQueue后,需要触发摘要。