2018-09-14 15:03:29 +01:00
|
|
|
// The function exported from this file is used by the protractor_web_test_suite.
|
|
|
|
// It is passed to the `onPrepare` configuration setting in protractor and executed
|
|
|
|
// before running tests.
|
|
|
|
//
|
|
|
|
// If the function returns a promise, as it does here, protractor will wait
|
|
|
|
// for the promise to resolve before running tests.
|
|
|
|
|
2019-07-24 08:52:26 -07:00
|
|
|
const protractorUtils = require('@bazel/protractor/protractor-utils');
|
2018-09-14 15:03:29 +01:00
|
|
|
const protractor = require('protractor');
|
|
|
|
|
|
|
|
module.exports = function(config) {
|
2019-07-24 08:52:26 -07:00
|
|
|
// In this example, `@bazel/protractor/protractor-utils` is used to run
|
2018-09-14 15:03:29 +01:00
|
|
|
// the server. protractorUtils.runServer() runs the server on a randomly
|
|
|
|
// selected port (given a port flag to pass to the server as an argument).
|
|
|
|
// The port used is returned in serverSpec and the protractor serverUrl
|
|
|
|
// is the configured.
|
2019-05-09 11:25:27 +03:00
|
|
|
const portFlag = /prodserver(\.exe)?$/.test(config.server) ? '-p' : '-port';
|
2018-09-14 15:03:29 +01:00
|
|
|
return protractorUtils.runServer(config.workspace, config.server, portFlag, [])
|
|
|
|
.then(serverSpec => {
|
|
|
|
const serverUrl = `http://localhost:${serverSpec.port}`;
|
|
|
|
protractor.browser.baseUrl = serverUrl;
|
|
|
|
});
|
|
|
|
};
|