【发布时间】:2021-05-28 15:42:15
【问题描述】:
我正在尝试执行角度测试用例,但每次执行时都会出现断开连接错误。
目前我已经编写了超过 1500 个测试用例,所以执行它可能需要时间,所以有什么方法可以在执行大量测试用例时修复断开连接错误。
以下是我在执行它时遇到的错误。
26 02 2021 10:36:47.160:DEBUG [Chrome 88.0.4324.150 (Linux x86_64)]: Disconnected during run, waiting 910000ms for reconnecting.
26 02 2021 10:36:47.160:DEBUG [Chrome 88.0.4324.150 (Linux x86_64)]: EXECUTING -> EXECUTING_DISCONNECTED
26 02 2021 10:51:57.169:WARN [Chrome 88.0.4324.150 (Linux x86_64)]: Disconnected (0 times)reconnect failed before timeout of 910000ms (ping timeout)
26 02 2021 10:51:57.170:DEBUG [Chrome 88.0.4324.150 (Linux x86_64)]: EXECUTING_DISCONNECTED -> DISCONNECTED
我试图增加等待时间,但它仍然没有为我工作。
以下是我运行的命令:
ng test --code-coverage --watch=false --browsers=Chrome
我的 Karma 文件配置如下:
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma'),
],
client: {
config: {
browserConsoleLogOptions: true,
},
captureConsole: true,
mocha: {
bail: true
},
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage'),
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
// reporters: ['progress', 'mocha', 'coverage'],
port: 9876,
colors: true,
logLevel: config.LOG_DEBUG,
autoWatch: true,
browsers: ['Chrome'],
captureTimeout: 210000,
browserDisconnectTolerance: 3,
browserDisconnectTimeout : 910000,
browserNoActivityTimeout : 910000,
singleRun: false
});
};
所以,有没有什么解决方案可以在 Angular 应用程序中执行超过 1500 个测试用例。
提前致谢。
【问题讨论】:
-
尝试稍微更新一下你的 karma npm 包,尤其是
karma-chrome-launcher。 -
确定@AliF50 会检查并通知您
-
嗨@AliF50 这个解决方案也对我不起作用
标签: angular typescript angular6 karma-coverage angular-test