我在1年前使用過Karma,一切正常。當我更改測試並保存.test.js文件時,測試自動運行 - 不必重新啓動或更改任何內容。 今天我想再次運行這些測試。擁有一臺新電腦,我必須安裝節點,NPM和諸如此類的東西,然後我也裝:Karma自動手錶不能正常工作
npm install -g karma karma-cli karma-jasmine karma-chrome-launcher
我配置噶如下(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 start karma.conf.js
)打開了一個新的chrome選項卡,並在配置文件中指定端口。測試運行,一切按預期工作。但是,當我在.test.js
文件中更改某些內容時,Karma未自動運行。其實,沒有改變。我必須重新啓動CMD中的Karma並再次運行才能看到新的結果。
但是,如果我打開一個新的CMD並執行karma run
測試得到更新。所以,顯而易見,觀察變化的部分不起作用。
所以,我不知道我在這裏錯過了什麼,但Karma的自動監視功能不再工作。我應該從哪裏開始建議?
你曾經能夠解決這個問題?如果是這樣,請發佈您的答案。 – Chic