Travis 在 "The SUID sandbox helper binary was found, but..." 上构建失败

Travis build failing on "The SUID sandbox helper binary was found, but..."

我的 Angular 应用程序测试在本地通过,但是它们在 travis 上失败并出现以下错误:

The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /opt/google/chrome/chrome-sandbox is owned by root and has mode 4755.

我通过编辑我的 karma.conf.js 文件并将以下对象添加到我的 customLaunchers 来解决问题:

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

所以我的 karma.conf.js 如下所示:

module.exports = function (config) {
  config.set({
    // other parameters...
    browsers                : [
      'ChromeHeadlessNoSandbox'
       // other browsers (if any)
    ],
    customLaunchers: {
      ChromeHeadlessNoSandbox: {
        base: 'ChromeHeadless',
        flags: ['--no-sandbox']
      }
      // other browsers (if any)
    },
  });
};

然后我 运行 我的测试 --browser=ChromeHeadlessNoSandbox