gpt4 book ai didi

javascript - Grunt Karma 运行测试但阻止

转载 作者:行者123 更新时间:2023-11-28 01:26:10 25 4
gpt4 key购买 nike

我有一个使用 Phantom JS 运行 Karma 单元测试的繁重任务。测试运行但任务不退出。这会阻止任何其他任务启动,直到我使用 ctrl+c 手动终止 karma:unit 任务。

我的 karma.conf.js 文件是:

// Karma configuration
// Generated on Thu Mar 06 2014 13:17:21 GMT-0500 (Eastern Standard Time)

module.exports = function(config) {
config.set({

// base path, that will be used to resolve files and exclude
basePath: '',


// frameworks to use
frameworks: ['mocha', 'requirejs', 'chai', 'sinon'],


// list of files / patterns to load in the browser
files: [
{ pattern: 'src/vendor/**/*.js', included: false },
{ pattern: 'src/*.js', included: false },
{ pattern: 'src/app/*_test.js', included: false },
{ pattern: 'src/app/**/*.js', included: false },
{ pattern: 'src/app/*_test.js', included: false },
'test-main.js'
],


// list of files to exclude
exclude: [
'src/app/main.js',
'**/Gruntfile.js'
],


// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress', 'coverage'],
preprocessors: {
'src/app/**/!(*_test).js': 'coverage'
},


// 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: false,


// 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: ['PhantomJS'],


// If browser does not capture in given timeout [ms], kill it
captureTimeout: 10000,


// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: true
});
};

我的 karma 任务的 Grunt 配置是:

karma: {
options: {
configFile: 'karma.conf.js'
},
unit: {
autowatch: true,
singleRun: true,
}
},

当我运行 grunt karma:unit 时,我得到:

Running "karma:unit" (karma) task
INFO [karma]: Karma v0.12.0 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.7 (Windows 7)]: Connected on socket V2NFfUtyUi_gl0gWqbov with id 17494532
PhantomJS 1.9.7 (Windows 7): Executed 2 of 2 SUCCESS (0.012 secs / 0 secs)

但在我按 ctrl+C 之前,它永远不会完成,没有错误

最佳答案

我在项目中重新安装了 karma 和 PhantomJS,问题就解决了。我注意到,当我更改 karma 配置以使用 Chrome 时,一切正常,所以我认为问题一定出在 PhantomJS

npm install karma --save-dev

npm install phantomjs --save-dev

关于javascript - Grunt Karma 运行测试但阻止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22644266/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com