我正在尝试将业力测试作为自动TFS构建的一部分。构建打开浏览器窗口,无法在构建服务器上无头运行。此方案的最佳浏览器配置是什么? 谢谢!
package.json脚本是
"headlessTest":"karma start --browsers ChromeHeadless karma.conf.js"
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma'),
require('karma-phantomjs-launcher')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};

在TFS构建中的控制台窗口中输出
[33m01 08 2017 10:03:00.043:WARN [launcher]: [39mChromeHeadless have not
captured in 60000 ms, killing.
[33m01 08 2017 10:03:02.087:WARN [launcher]: [39mChromeHeadless was not
killed in 2000 ms, sending SIGKILL.
[33m01 08 2017 10:03:04.208:WARN [launcher]: [39mChromeHeadless was not``killed by SIGKILL in 2000 ms, continuing.
答案 0 :(得分:1)
您可以尝试使用" nosandbox"。
来制作Chrome在您的业力project.conf.js
中使用以下配置:
browsers: ['ChromeNoSandbox'],
customLaunchers: {
ChromeNoSandbox: {
base: 'Chrome',
flags: ['--no-sandbox']
}
}
参考此Github问题:https://github.com/karma-runner/karma-chrome-launcher/issues/73#issuecomment-236597429
<强>更新强>
Karma存在一个问题:github.com/karma-runner/karma/issues/2652,无论您为Karma和Chrome尝试不同的版本组合,有人都提到downgrading to karma 1.5有效。
您也可以尝试增加Timeout值,例如600000,然后再试一次。