Search code examples
angularprotractorangular-cliend-to-end

MultiCapabilities configuration error


I am having an error while using multiCapabilities with two browsers (Firefox and Chrome). This is an extract from my config:

exports.config = {
  allScriptsTimeout: 11000,

  seleniumAddress: 'http://localhost:4444/wd/hub',

  baseUrl: 'http://localhost:4200',

  specs: [
    './e2e/features/*.ts'
  ],

  multiCapabilities: [
    {'browserName': 'chrome'},
    {'browserName': 'firefox'}
  ],

  directConnect: false,

  framework: 'custom',

  frameworkPath: require.resolve('serenity-js'),

  cucumberOpts: {
    compiler: "ts:ts-node/register",
    tags: [],                      // <string[]> (expression) only execute the features or scenarios with tags matching the expression
    strict: true,                  // <boolean> fail if there are any undefined or pending steps
    dryRun: false,                 // <boolean> invoke formatters without executing steps
    compiler: [],
    require: ['./e2e/steps/*.ts'],  // require step definition files before executing features
    format: ["pretty"] // <string[]> (type[:path]) specify the output format, optionally supply PATH to redirect formatter output (repeatable)
  },

  beforeLaunch: function() {
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'
    });
  },

  onPrepare: function () {
    browser.ignoreSynchronization = true;
    browser.driver.manage().window().setSize(1800, 1500);
  }

The beginning of my step file:

import { browser, element, by } from 'protractor';
import { binding, given, when, then } from "cucumber-tsflow";
import { CallbackStepDefinition } from 'cucumber';

The error get, only when running two browsers at the same time is this one:

[15:12:32] I/launcher - Running 2 instances of WebDriver
[15:12:36] I/testLogger -
------------------------------------

[15:12:36] I/testLogger - [chrome #11] PID: 12332
[chrome #11] Specs: C:\Users\JeanB\work_projects\dealflo-cwf-ux\e2e\features\footer-component.feature.ts
[chrome #11]
[chrome #11] (node:12332) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[chrome #11] [15:12:33] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[chrome #11] [15:12:36] I/runnerCli - Unexpected token import

[15:12:36] I/testLogger -

[15:12:36] E/launcher - Runner process exited unexpectedly with error code: 1
[15:12:36] I/launcher - 1 instance(s) of WebDriver still running
[15:12:37] I/testLogger -
------------------------------------

[15:12:37] I/testLogger - [firefox #01] PID: 14720
[firefox #01] Specs: C:\Users\JeanB\work_projects\dealflo-cwf-ux\e2e\features\footer-component.feature.ts
[firefox #01]
[firefox #01] (node:14720) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[firefox #01] [15:12:33] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[firefox #01] [15:12:37] I/runnerCli - Unexpected token import

[15:12:37] I/testLogger -

[15:12:37] E/launcher - Runner process exited unexpectedly with error code: 1
[15:12:37] I/launcher - 0 instance(s) of WebDriver still running
[15:12:37] I/launcher - chrome #11 failed with exit code: 1
[15:12:37] I/launcher - firefox #01 failed with exit code: 1
[15:12:37] I/launcher - overall: 2 process(es) failed to complete
[15:12:37] E/launcher - Process exited with error code 100

I'm using the protractor 5.1.2 with cucumber-js 1.3 Is this a bug or a problem with my configuration?


Solution

  • I finally found a thread in the angular-cli github. Link to angular-cli issue Basically, the beforeLaunch is run once, so, if using multiCapabilities with angular-cli.

    require('ts-node').register({
       project: 'e2e/tsconfig.e2e.json'
    });
    

    Need to be moved to the OnPrepare.

    You can find more about it if you follow the link.