我有一个用Coffeescript编写的网络应用程序,我正在使用Karma进行测试。我的测试是写的,我现在正在编写代码以使测试通过。
目前,每当我更改代码时,我都需要通过在终端中键入grunt karma
来手动重新运行我的测试。有没有办法设置业力,以便在我的.coffee文件发生变化时自动重新运行我的测试?
这是我的karma.conf.js
:
// Karma configuration
// http://karma-runner.github.io/0.10/config/configuration-file.html
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
preprocessors: {
'**/*.coffee': ['coffee']
},
coffeePreprocessor: {
// options passed to the coffee compiler
options: {
bare: true,
sourceMap: false
},
// transforming the filenames
transformPath: function(path) {
return path.replace(/\.coffee$/, '.js')
}
},
// testing framework to use (jasmine/mocha/qunit/...)
frameworks: ['jasmine'], //,'requirejs'],
// list of files / patterns to load in the browser
files: [
'app/bower_components/**/*.js',
'app/scripts/*.js',
'app/scripts/**/*.js',
'test/spec/**/*.coffee',
'.tmp/scripts/**/*.js'
],
// list of files / patterns to exclude
exclude: [],
// web server port
port: 8080,
// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true, // change by davebenson. was false
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['Chrome'],
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
});
};