简体   繁体   中英

Force Karma to take updated spec.js file from disk

I'm writing test specs for angular controllers, say something like this:

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();
});

Then, I need to test it to see if it works. So I run:

karma start

In a command window. Soon after I realize I need to use scope instead of $scope , so I save the spec.js file, CTRL + C in the Karma window, re-open the browser, press debug and try again. This goes on and on when I'm writing test specs.

Can I force Karma to just take the latest spec.js file from disk without having me repeat this process?

Use the autowatch swtich when you run it:

--autoWatch

and you can also tell it to wait for a set amount of time before it runs with the autoWatchBatchDelay:

autoWatchBatchDelay:500

It's all in the config options: http://karma-runner.github.io/0.13/config/configuration-file.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM