blob: a1f7267cdee57dba103c080ccc2b0cd136ffa7cf [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
Philipp Schrader817cce32022-03-26 15:00:00 -070011module.exports = function (config) {
Philipp Schraderd999c9f2022-02-27 15:48:58 -080012 // 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
Philipp Schrader817cce32022-03-26 15:00:00 -070018 .runServer(config.workspace, config.server, '--port', [])
19 .then((serverSpec) => {
20 protractor.browser.baseUrl = `http://localhost:${serverSpec.port}`;
21 });
Philipp Schraderd999c9f2022-02-27 15:48:58 -080022};