当使用Karma和chrome headless在Jenkins中运行单元测试时,出现此错误:
HeadlessChrome 61.0.3163(Linux 0.0.0):执行143次成功143次成功(0秒/ 13分钟41.046秒) 10 02 2019 18:04:43.383:WARN [HeadlessChrome 61.0.3163(Linux 0.0.0)]:断开连接(1次) [1A [2K [1A [2KHeadlessChrome 61.0.3163(Linux 0.0.0)错误 断开未定义
问题是Chrome尝试重新连接时会跳过其他测试(从143到876,并且覆盖范围不稳定)
NB:我将Karma配置为使用2个执行程序和轮询策略,我的Karma配置如下:
logLevel: config.LOG_INFO,
autoWatch: false,
singleRun: true,
browsers: ['HeadlessChrome'],
customLaunchers:{
HeadlessChrome:{
base: 'Chrome',
flags: [
'--no-sandbox',
'--headless',
'--disable-web-security',
'--remote-debugging-port=9222'
]
}
},
captureTimeout: 100000,
browserDisconnectTimeout : 30000,
browserDisconnectTolerance : 2,
browserNoActivityTimeout : 120000,
我的依赖项是:
"karma": "^1.7.1",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.3.3",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-junit-reporter": "^1.2.0",
"karma-parallel": "^0.2.9",