blob: 7919fe73bcb0fc956348dd2eaec109c6f50da3ed [file] [log] [blame]
Philipp Schraderd999c9f2022-02-27 15:48:58 -08001// The function exported from this file is used by the protractor_web_test_suite.
2// It is passed to the `onPrepare` configuration setting in protractor and executed
3// before running tests.
4//
5// If the function returns a promise, as it does here, protractor will wait
6// for the promise to resolve before running tests.
7
8const protractorUtils = require('@bazel/protractor/protractor-utils');
9const protractor = require('protractor');
10
11module.exports = function(config) {
12 // In this example, `@bazel/protractor/protractor-utils` is used to run
13 // the server. protractorUtils.runServer() runs the server on a randomly
14 // selected port (given a port flag to pass to the server as an argument).
15 // The port used is returned in serverSpec and the protractor serverUrl
16 // is the configured.
17 return protractorUtils
18 .runServer(config.workspace, config.server, '--port', [])
19 .then(serverSpec => {
20 protractor.browser.baseUrl = `http://localhost:${serverSpec.port}`;
21 });
22};