0
votes

I'm having a not very meaningful error on my gitlab CI server when running e2e tests.

[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! [email protected] e2e-ci: `ng e2e --conf protractor-ci.conf.js`
npm ERR! Exit status 100
npm ERR! 
npm ERR! Failed at the [email protected] 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

Here is the 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 } }));
  }
};

the job desciption in my 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

And here is my 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"
  • "karma": "~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"
  • "protractor": "~5.1.2"
  • "ts-node": "~3.2.0"
  • "tslint": "~5.7.0"
  • "typescript": "~2.4.2"

I've been struggling on setting up the CI for a little while now so any suggestions will be very much appreciated ^^'

1

1 Answers

-1
votes

Just use image with headless chrome preinstalled. Here is my script for Gitlab pipelines:

cache:
  paths:
    - node_modules/

before_script:
  - npm cache clean --force
  - npm install && npm rebuild

stages:
  - test
  - build


build:
  image: node:alpine
  stage: build
  script:
    - ./node_modules/@angular/cli/bin/ng build --prod

test:
  image: gnomeontherun/docker-node-chrome-headless:latest
  stage: test
  script:
    - ./node_modules/@angular/cli/bin/ng test --watch=false --single-run=true