Skip to content

build: prevent binding BrowserSync UI server during test execution #23733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tools/dev-server/dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ export class DevServer {
};

constructor(
readonly port: number, private _rootPaths: string[],
private _historyApiFallback: boolean = false) {}
readonly port: number, private _rootPaths: string[], bindUi: boolean,
private _historyApiFallback: boolean = false) {
if (bindUi === false) {
this.options.ui = false;
}
}

/** Starts the server on the given port. */
start() {
Expand Down
4 changes: 2 additions & 2 deletions tools/dev-server/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ const {root_paths: _rootPathsRaw, port, historyApiFallback} =
minimist(args, {boolean: 'historyApiFallback'});
const rootPaths = _rootPathsRaw ? _rootPathsRaw.split(',') : ['/'];

const server = new DevServer(port, rootPaths, historyApiFallback);
const bindUi = process.env.TEST_TARGET === undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional when you have time: A small comment would be good here, saying that for tests like e2e the UI is not reasonable to serve, and it could cause port conflicts.

const server = new DevServer(port, rootPaths, bindUi, historyApiFallback);

// Setup ibazel support.
setupBazelWatcherSupport(server);

// Start the devserver. The server will always bind to the loopback and
// the public interface of the current host.
server.start();