首页 > 解决方案 > 如何在 Cloud Builders 中成功运行 Protractor e2e 测试?

问题描述

我正在为我们在 Angular 中的项目设置 CI。我们正在使用 Google Cloud Platform 的 Cloud Builder for CI。一切都很顺利,我们可以设置环境,通过 安装包,使用和部署npm构建项目。angular-cli但问题是我们在量角器中的测试用例(e2e)不断出错。我们在这里缺少什么?

这是为了使用 Google Cloud Builders 进行持续集成,我们在无头模式下运行量角器,并使用 puppeteer 的 chromium 作为 chrome 的二进制路径

这是我的量角器.conf.js

// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts

const { SpecReporter } = require('jasmine-spec-reporter');
const puppeteer = require('puppeteer');
process.env.CHROME_BIN = puppeteer.executablePath()

exports.config = {
  allScriptsTimeout: 1000000,
  specs: [
    './e2e/*.e2e-spec.ts',
    '../e2e/*.e2e-spec.ts'
  ],

  capabilities: {
    // browserName: 'chrome',
    browserName: 'chrome',
    chromeOptions: {
      binary: process.env.CHROME_BIN,
      args: ['--headless', '--disable-gpu', '--no-sandbox', '--disable-extensions', '--disable-dev-shm-usage', '--disable-setuid-sandbox']
    }
  },
  // seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
  // ignoreUncaughtExceptions: true,
  directConnect: true,
  },
};

这是我们在云构建器中遇到的错误

[11:24:12] E/launcher - unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /workspace/node_modules/puppeteer/.local-chromium/linux-662092/chrome-linux/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-1033-gcp x86_64)
[11:24:12] E/launcher - WebDriverError: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /workspace/node_modules/puppeteer/.local-chromium/linux-662092/chrome-linux/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

标签: seleniumdockergoogle-cloud-platformprotractorcontinuous-integration

解决方案


推荐阅读