0

I want to integrate my E2E suite in Travis, so I followed this article. As mentioned in the article I've created a custom protractor.ci.conf.js file of the Travis build. I've placed this file inside my e2e folder (path: e2e/protractor.ci.conf.js).

The only difference in my custom e2e/protractor.ci.conf.js and angular generated protractor.conf.js files is the value in args property displayed below.

e2e/protractor.ci.conf.js

chromeOptions: {
      args: [
        '--headless',
        'window-size=1920,1080'
      ]
    }

protractor.conf.js

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

exports.config = {
  allScriptsTimeout: 11000,
  specs: [
   './e2e/**/*.e2e-spec.ts'
  ],
  capabilities: {
    shardTestFiles: true,
    maxInstances: 2,
    'browserName': 'chrome',
    chromeOptions: {
      args: ['--start-maximized']
    }
  },
  directConnect: true,
  baseUrl: 'localhost:4000/',
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 300000,
    print: function () {
    }
  },
  useAllAngular2AppRoots: true,
  onPrepare: function () {
    jasmine.getEnv().addReporter(new SpecReporter());
    require('ts-node').register({
      project: 'e2e/tsconfig.json'
    });
  }
};

In my package.json file there are 2 scripts one for running tests locally and one on Travis.

Package.json (at the same level where protractor.conf.js is located)

 "scripts": {
    ...
    "test": "ng test --watch=false",
    "pree2e": "webdriver-manager update",
    "e2e": "concurrently --kill-others \"ng e2e --port=4000\" \"npm run _server:run\"",
    "e2e:ci": "concurrently --kill-others \"ng e2e --port=4000 --protractor-config=e2e/protractor.ci.conf.js\" \"npm run _server:run\"",
    "_server:run": "tsc -p ./server && concurrently \"tsc -w -p ./server\" \"nodemon dist/server/index.js\" ",
    ...
  },

.travis.yml

branches:
 only:
  - staging
  - prod
  - functional-testing
 script:
   ...
  - if [[ $TRAVIS_COMMIT_MESSAGE == *"[skip e2e]"* ]]; then echo "skipping E2E test"; else npm run e2e:ci; fi
  ...
before_deploy:
  - sed -i '/dist/d' .gitignore
  - git add . && git commit -m "latest build"
  - cd $TRAVIS_BUILD_DIR/dist

PROBLEM

When simply running npm run e2e, every test is working fine. But when I'm using npm run e2e:ci command scripts hangs and no instance of WebDriver runs.

I/launcher — Running 0 instances of WebDriver

is coming instead of 1 or 2 instances.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.