Karma Disconnected 在超时 Nightmare 之前重新连接失败

Karma Disconnected reconnect failed before timeout Nightmare

我的 angular 应用程序有超过 5000 个测试用例。

在升级到Angular13和Karma 6.3、Jasmin 3.6之前一直运行没问题

升级后,我在 运行“ng 测试”时遇到此错误。

Disconnected reconnect failed before timeout of 960000ms (transport close)

这就是我的业力配置在

之后的样子
const process = require("process");
process.env.CHROME_BIN = require("puppeteer").executablePath();

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'),
      require('karma-junit-reporter')
    ],
    client: {
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, '../coverage'),
      reports: ['html', 'lcovonly','text-summary', 'cobertura'],
      fixWebpackSourcePaths: true,
    },
    reporters: ['progress', 'kjhtml','coverage-istanbul'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    // autoWatch: true,
    // browsers: ['ChromeHeadless'],
    autoWatch: false,
    browsers: ['ChromeHeadlessNoSandbox'],
    singleRun: true,
    customLaunchers: {
      ChromeHeadlessNoSandbox: {
        base: 'ChromeHeadless',
        flags: [
          '--no-sandbox',
          '--disable-gpu',
          '--js-flags=--max-old-space-size=80196',
          '--disable-web-security'
        ],
      },
    },
    browserNoActivityTimeout: 960000,
        browserDisconnectTimeout: 960000,
    proxies: {
      '/assets/': '/base/src/assets/',
    },
  });

};

和package.json的一部分

 "jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "^6.3.13",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "^2.0.6",
"karma-jasmine": "~4.0.0",

我几乎尝试了所有 github 和 Whosebug,以及其他建议,与许多专家交谈,但没有成功。

经过更多阅读,这就是我解决问题的方法。

我确保所有测试包的版本都正确更新并且相互兼容。

这是现在的样子,

"jasmine-core": "4.0.1",
"jasmine-spec-reporter": "7.0.0",
"karma": "6.3.17",
"karma-chrome-launcher": "3.1.1",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-jasmine": "4.0.2"

在此之后,我能够运行所有的测试用例。