我大约1年前使用过Karma,一切正常.当我更改测试并保存.test.js文件时,测试自动运行 – 不必重新启动或更改任何内容.
今天我想再次运行这些测试.有了一台新电脑,我不得不安装node和npm以及whatnot,然后我也安装了:
npm install -g karma karma-cli karma-jasmine karma-chrome-launcher
我按如下方式配置了Karma(karma init):
// Karma configuration
// Generated on Thu Apr 14 2016 14:50:35 GMT+0200 (Central Europe Summer Time)
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: [
'js/*.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: {
},// test results reporter to use
// possible values: 'dots','progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],// 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,// 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,// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
当我开始karma(karma start karma.conf.js)时,会打开一个新的chrome选项卡,其中包含在配置文件中指定的端口.测试运行,一切都按预期工作.但是,当我在.test.js文件中更改了某些内容时,Karma没有自动运行.实际上,没有做出任何改变.我不得不在CMD中重新启动Karma并再次运行以查看新结果.
但是,如果我打开一个新的CMD并执行karma运行,测试会更新.因此,显然,注意变化的部分不起作用.
最佳答案