您好我有以下配置和简单测试,我通过输入'karma start'来运行业力 。它运行并成功通过,但是,当我编辑并保存simpletest.js文件时没有任何反应......
知道为什么吗?我将autoWatch设置为true,将singleRun设置为false。
Simpletest.js
describe("my simple test", function() {
it("should have an expected result", function() {
expect(true).to.be.true;
});
});
Karma.conf.js
// Karma configuration
// Generated on Wed Feb 19 2014 22:59:38 GMT+0000 (GMT)
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
// frameworks to use
frameworks: ['mocha' , 'sinon-chai'],
// list of files / patterns to load in the browser
files: [
'simpletest.js'
],
// list of files to exclude
exclude: [
],
// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
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, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera (has to be installed with `npm install karma-opera-launcher`)
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
// - PhantomJS
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
browsers: ['Chrome'],
// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false,
client: {
mocha: {
ui: 'bdd'
}
}
});
};
在 logLevel:config.LOG_DEBUG 启用时运行
DEBUG [plugin]: Loading karma-* from c:\dev\karmaspike\node_modules
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-chrome-launcher.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-coffee-preprocessor.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-firefox-launcher.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-html2js-preprocessor.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-jasmine.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-mocha.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-phantomjs-launcher.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-requirejs.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-script-launcher.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-sinon-chai.
INFO [karma]: Karma v0.10.9 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
DEBUG [launcher]: Creating temp dir at C:\Users\Mantisimo\AppData\Local\Temp\karma-76378892
DEBUG [launcher]: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --user-data-dir=C:\Users\Kevin\AppData\Loc
al\Temp\karma-76378892 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --start
-maximized http://localhost:9876/?id=76378892
DEBUG [watcher]: Resolved files:
c:\dev\karmaspike\node_modules/karma-sinon-chai/bower_components/sinonjs/sinon.js
c:\dev\karmaspike\node_modules/karma-sinon-chai/node_modules/chai/chai.js
c:\dev\karmaspike\node_modules/karma-sinon-chai/node_modules/sinon-chai/lib/sinon-chai.js
c:\dev\karmaspike\node_modules/karma-sinon-chai/adapter.js
c:\dev\karmaspike\node_modules/mocha/mocha.js
c:\dev\karmaspike\node_modules/karma-mocha/lib/adapter.js
c:\dev\karmaspike\simpletest.js
DEBUG [watcher]: Watching "c:\dev\karmaspike\simpletest.js"
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules\karma\static/client.html
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules\karma\static/karma.js
DEBUG [karma]: A browser has connected on socket PQ8_7xQOVC4GgFVebJZU
INFO [Chrome 32.0.1700 (Windows)]: Connected on socket PQ8_7xQOVC4GgFVebJZU
DEBUG [karma]: All browsers are ready, executing
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules\karma\static/context.html
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules/karma-sinon-chai/node_modules/chai/chai.js
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules/karma-sinon-chai/bower_components/sinonjs/sinon
.js
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules/karma-sinon-chai/node_modules/sinon-chai/lib/si
non-chai.js
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules/karma-sinon-chai/adapter.js
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules/mocha/mocha.js
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules/karma-mocha/lib/adapter.js
DEBUG [web-server]: serving: c:\dev\karmaspike\simpletest.js
Chrome 32.0.1700 (Windows): Executed 1 of 1 SUCCESS (0.287 secs / 0 secs)
答案 0 :(得分:0)
基础路径不应该是相对路径。
像basePath : './'
这样的东西,以便它在与配置相同的目录中查找文件?
您是否尝试在测试中设置控制台日志并将karma设置为输出调试日志语句?这可以告诉你测试是否正在运行..
logLevel: config.LOG_DEBUG,