在gitlab CI上运行角度e2e测试时出错

时间:2017-11-28 23:55:10

标签: protractor continuous-integration gitlab-ci e2e-testing angularjs-e2e

运行e2e测试时,我的gitlab CI服务器上出现了一个非常有意义的错误。

[22:40:18] I/launcher - Running 1 instances of WebDriver
[22:40:18] I/local - Starting selenium standalone server...
[22:40:18] E/launcher - Error: Error: Server terminated early with status 1
    at earlyTermination.catch.e (/selenium-webdriver/remote/index.js:252:52)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
[22:40:18] E/launcher - Process exited with error code 100
npm ERR! code ELIFECYCLE
npm ERR! errno 100
npm ERR! guide-scanner-web@0.0.0 e2e-ci: `ng e2e --conf protractor-ci.conf.js`
npm ERR! Exit status 100
npm ERR! 
npm ERR! Failed at the guide-scanner-web@0.0.0 e2e-ci script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2017-11-28T22_40_19_015Z-debug.log
ERROR: Job failed: exit code 1

这是protractor.conf.js

const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
  allScriptsTimeout: 11000,
  specs: [
    './e2e/**/*.e2e-spec.ts'
  ],
  capabilities: {
    'browserName': 'chrome',
    'chromeOptions': {
      args: ["--headless", '--no-sandbox', "--disable-gpu", "--window-size=800x600"]
    }
  },
  chromeDriver: '/selenium-grid/chromedriver_2.33',
  seleniumServerJar: "/selenium-grid/selenium-server-standalone-3.7.1.jar",
  baseUrl: 'http://localhost:4200/',
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {}
  },
  onPrepare() {
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'
    });
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
  }
};

我的gitlab-ci.yml中的工作原理

before_script:
  - npm install

e2e:
  stage: testing
  script:
    - apt-get update -y
    - apt-get install default-jre -y
    - npm install -g webdriver-manager
    - webdriver-manager update --out_dir /selenium-grid
    - npm run e2e

这是我的package.json:

  • “@ angular / language-service”:“^ 5.0.0”
  • “@ types / jasmine”:“~2.5.53”
  • “@ types / jasminewd2”:“~2.0.2”
  • “@ types / node”:“~6.0.60”
  • “codelyzer”:“~3.2.2”
  • “jasmine-core”:“~2.6.2”
  • “jasmine-spec-reporter”:“~4.1.0”
  • “业力”:“~1.7.0”
  • “karma-chrome-launcher”:“〜2.1.1”
  • “karma-cli”:“~1.0.1”
  • “karma-coverage-istanbul-reporter”:“^ 1.2.1”
  • “karma-jasmine”:“~1.1.0”
  • “karma-jasmine-html-reporter”:“^ 0.2.2”
  • “量角器”:“~5.1.2”
  • “ts-node”:“~3.2.0”
  • “tslint”:“~5.7.0”
  • “typescript”:“~2.4.2”

我一直在努力设置CI一段时间,所以任何建议都会非常感激^^'

1 个答案:

答案 0 :(得分:0)

只需使用预装无头镀铬的图像。这是我的Gitlab管道脚本:

joblib