Skip to content

fix(@angular-devkit/build-angular): e2e does not respect dev-server `… #14165

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 7, 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
17 changes: 14 additions & 3 deletions packages/angular_devkit/build_angular/src/protractor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,21 @@ async function execute(
const serverOptions = await context.getTargetOptions(target);

const overrides: Record<string, string | number | boolean> = { watch: false };
if (options.host !== undefined) { overrides.host = options.host; }
if (options.port !== undefined) { overrides.port = options.port; }
server = await context.scheduleTarget(target, overrides);
if (options.host !== undefined) {
overrides.host = options.host;
} else if (typeof serverOptions.host === 'string') {
options.host = serverOptions.host;
} else {
options.host = overrides.host = 'localhost';
}

if (options.port !== undefined) {
overrides.port = options.port;
} else if (typeof serverOptions.port === 'number') {
options.port = serverOptions.port;
}

server = await context.scheduleTarget(target, overrides);
let result;
try {
result = await server.result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
},
"host": {
"type": "string",
"description": "Host to listen on.",
"default": "localhost"
"description": "Host to listen on."
},
"baseUrl": {
"type": "string",
Expand Down
28 changes: 28 additions & 0 deletions tests/legacy-cli/e2e/tests/misc/e2e-host.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as os from 'os';
import { killAllProcesses, ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';

export default async function () {
const interfaces = [].concat.apply([], Object.values(os.networkInterfaces()));
let host = '';
for (const { family, address, internal } of interfaces) {
if (family === 'IPv4' && !internal) {
host = address;
break;
}
}

try {
await updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.serve.options.port = 8888;
appArchitect.serve.options.host = host;
});

await ng('e2e');

await ng('e2e', '--host', host);
} finally {
await killAllProcesses();
}
}