在 x 毫秒超时之前断开重新连接失败(传输关闭)

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

我在 Windows 上使用 --no-sandbox 标志进行 运行 测试时遇到问题。没有它,它可以正常工作,但如果没有,我会得到错误

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

在 docker 中,使用 --no-sandbox 标志运行时没有任何问题,如果没有该标志,它表示它不受支持或类似的东西。

你遇到过这样的问题吗?你是怎么解决的?

我查了stack和web上的大部分问题,但是好像都没有解决这个问题。

我试过 - 设置额外的、不同的标志,但是 none 的设置有效

我尝试删除此标志 - 但在 docker 中需要这样做。

我尝试更新所有测试库 - 没有任何帮助。

这是我的业力配置

// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

// this ensures we always have a fresh chrome copy
// and that it's usable in a ci/cd perspective
const process = require('process');

process.env.CHROME_BIN = require('puppeteer').executablePath()

module.exports = function (config) {
  config.set({
    debugMode: true,
    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: {
      clearContext: false, // leave Jasmine Spec Runner output visible in browser
      jasmine: {
        random: false
      }
    },
    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, './coverage/Frontend'),
      reports: ['html', 'lcovonly', 'text-summary'],
      fixWebpackSourcePaths: true
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['ChromeHeadlessNoSandbox'],
    customLaunchers: {
      ChromeHeadlessNoSandbox: {
        base: 'ChromeHeadless',
        flags: [
          '--no-sandbox']
      }
    },
    singleRun: true,
    restartOnFileChange: true,
  });
};

如果可能的话,你可以有2个脚本。

尝试进行以下更改:

browsers: ['ChromeHeadlessNoSandbox', 'Chrome'],
    customLaunchers: {
      ChromeHeadlessNoSandbox: {
        base: 'ChromeHeadless',
        flags: [
          '--no-sandbox']
      }

package.json

"test": "ng test --browsers ChromeHeadlessNoSandbox",
"test:windows": "ng test --browsers Chrome"

类似的东西。基本上一个脚本用于 Windows 中的测试,另一个脚本用于 Docker/CI/CD.