My Karma installation used to auto-watch - when I saved a .js file, it'd re-run the tests. It's been a couple of months since I did any JavaScript, and now I come to use it again, the auto-watch feature isn't working. Here is my karma.conf:
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '../',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'jQuery/jquery-1.10.2.js',
'jasmine/jasmine.js',
'jasmine-jquery/jasmine-jquery.js',
'Angular/angular.js',
'Angular/angular-route.js',
'Angular/angular-mocks.js',
'Angular/angular-animate.min.js',
'Angular/angular-sanitize.min.js',
'Angular/angular-cache.min.js',
'emcommon.js',
'Moment/moment.js',
'ViewModels/Common/*.js',
'ViewModels/Settings/*.js',
'Tests/Common/*.js',
'Tests/Settings/*.js',
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'../ViewModels/**/*.js': 'coverage'
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'coverage'],
coverageReporter: {
type: 'html',
},
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
usePolling: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};
I've read and followed the advice here. I've tried setting usePolling
to true. I've used three different programs to save the file (VS, Sublime, and Notepad) to rule that out. If I stop Karma and restart it, it picks up the changes and they pass/fail as expected, but it will not see the files change while it's running.
Moving from Karma 0.12.7 to 0.13.0 makes no difference to the problem.