Skip to content

fix(@angular-devkit/build-angular): dev-server port number mismatches… #14500

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
May 23, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,9 @@ export function serveWebpackBrowser(

if (first) {
first = false;

context.logger.info(tags.oneLine`
**
Angular Live Development Server is listening on ${options.host}:${options.port},
Angular Live Development Server is listening on ${options.host}:${buildEvent.port},
open your browser on ${serverAddress}
**
`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,29 @@ describe('Dev Server Builder', () => {
expect(res).not.toContain('This file is automatically generated during release.');
expect(res).toContain('<title>HelloWorldApp</title>');
});

it('works with port 0', async () => {
const logger = new logging.Logger('');
const logs: string[] = [];
logger.subscribe(e => logs.push(e.message));

const run = await architect.scheduleTarget(target, { port: 0 }, { logger });
runs.push(run);
const output = await run.result as DevServerBuilderOutput;
expect(output.success).toBe(true);

const groups = logs.join().match(/\:(\d+){4,6}/g);
if (!groups) {
throw new Error('Expected log to contain port number.');
}

// tests that both the ports in the logs are the same.
const [firstPort, secondPort] = groups;
expect(firstPort).toBe(secondPort);

expect(output.baseUrl).toBe(`http://localhost${firstPort}/`);
const response = await fetch(`http://localhost${firstPort}/index.html`);
expect(await response.text()).toContain('<title>HelloWorldApp</title>');
});

});