强制Karma从磁盘获取更新的spec.js文件

时间:2015-09-25 23:18:56

标签: javascript angularjs jasmine karma-runner

我正在为角度控制器编写测试规范,比如说:

it('should have a method to add a blank category', function () {
    var controller = CategoryControllerCreator();
    $scope.allcategories = {};
    $scope.addCategoryStart();
    expect($scope.allcategories["ID-1"]).not.toBeUndefined();
});

然后,我需要测试一下它是否有效。所以我跑:

karma start

在命令窗口中。我意识到我需要使用scope代替$scope后不久,所以我将spec.js文件CTRL + C保存在Karma窗口中,重新打开浏览器,按调试然后再试一次。当我编写测试规范时,这种情况会持续下去。

我是否可以强制Karma从磁盘中获取最新的spec.js文件而不重复此过程?

1 个答案:

答案 0 :(得分:0)

运行时使用autowatch swtich:

--autoWatch

你也可以告诉它在使用autoWatchBatchDelay运行之前等待一段时间:

autoWatchBatchDelay:500

所有这些都在配置选项中:http://karma-runner.github.io/0.13/config/configuration-file.html