Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Protractor doesn't wait for beforeLaunch to be resolved when using multiple capabilities #3590

Open
@remcohaszing

Description

@remcohaszing

Bug report

When specifying multiple capabilities in the configuration file, protractor doesn't wait for the promise returned by beforeLaunch to be resolved.

  • Node Version: 6.6.0
  • Protractor Version: 4.0.8
  • Browser(s): Chrome / Firefox
  • Operating System and Version Ubuntu 16.04
  • Your protractor configuration file
'use strict';

/* eslint-env jasmine */

const path = require('path');

require('ts-node/register');
const reporters = require('jasmine-reporters');
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');


const config = {
  framework: 'jasmine',
  specs: ['app/**/*.e2e-spec.ts'],

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

  /**
   * These settings remove the need for Selenium.
   */
  chromeDriver: path.resolve(__dirname, 'node_modules/.bin/chromedriver'),
  directConnect: true,

  /**
   * Start a webpack dev server on a random port.
   *
   * The protractor `baseUrl` is set to this port on localhost.
   */
  beforeLaunch: () => {
    return new Promise(resolve => {
      setTimeout(() => {
        const compiler = webpack(require('./webpack.config'));
        const server = new WebpackDevServer(compiler, {
          stats: 'errors-only'
        });
        server.listen(0, 'localhost', () => {
          // `server.listeningApp` will be returned by `server.listen()`
          // in `webpack-dev-server@~2.0.0`
          const address = server.listeningApp.address();
          config.baseUrl = `http://localhost:${address.port}`;
          resolve();
        });
      }, 5000);
    });
  }
};


module.exports = {
  config
};
  • Steps to reproduce the bug
  • Create a minimal configuration file implementing a beforeLaunch function returning a promise, e.g. using a timeout.
  • Add one of:
    • capabilities,
    • multiCapabilities,
    • getMultiCapabilities
  • Notice that when a single capabilities object is added (either as capabilities or the only item of multiCapabilities or getMultiCapabilities), the tests won't run until the promise is resolved.
  • Add another capability
  • Notice that the tests are run before the promise is resolved.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions