Skip to content

Commit c74e33e

Browse files
committed
test: use random devserver ports
1 parent 6e8808e commit c74e33e

25 files changed

+38
-31
lines changed

packages/angular_devkit/build_angular/src/builders/dev-server/specs/works_spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('Dev Server Builder', () => {
3434
expect(output.success).toBe(true);
3535

3636
// When webpack-dev-server doesn't have `contentBase: false`, this will serve the repo README.
37-
const response = await fetch('http://localhost:4200/README.md', {
37+
const response = await fetch(`http://localhost:${output.port}/README.md`, {
3838
headers: {
3939
'Accept': 'text/html',
4040
},

packages/angular_devkit/build_angular/test/hello-world-app/protractor.conf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ exports.config = {
2323
},
2424
},
2525
directConnect: true,
26-
baseUrl: 'http://localhost:4200/',
26+
baseUrl: 'http://localhost:0/',
2727
framework: 'jasmine',
2828
jasmineNodeOpts: {
2929
showColors: true,

tests/legacy-cli/e2e/assets/12.0-project/e2e/protractor.conf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ exports.config = {
1414
browserName: 'chrome',
1515
},
1616
directConnect: true,
17-
baseUrl: 'http://localhost:4200/',
17+
baseUrl: 'http://localhost:0/',
1818
framework: 'jasmine',
1919
jasmineNodeOpts: {
2020
showColors: true,

tests/legacy-cli/e2e/assets/13.0-project/e2e/protractor.conf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ exports.config = {
1414
browserName: 'chrome',
1515
},
1616
directConnect: true,
17-
baseUrl: 'http://localhost:4200/',
17+
baseUrl: 'http://localhost:0/',
1818
framework: 'jasmine',
1919
jasmineNodeOpts: {
2020
showColors: true,

tests/legacy-cli/e2e/tests/basic/e2e.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ export default async function () {
55
await expectToFail(() => silentNg('e2e', 'test-project', '--dev-server-target='));
66

77
// These should work.
8-
await silentNg('e2e', 'test-project');
9-
await silentNg('e2e', 'test-project', '--dev-server-target=test-project:serve');
8+
await silentNg('e2e', '--port=0', 'test-project');
9+
await silentNg('e2e', '--port=0', 'test-project', '--dev-server-target=test-project:serve');
1010
}

tests/legacy-cli/e2e/tests/basic/standalone.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ export default async function () {
5454
await ng('build');
5555

5656
// Perform the default E2E tests
57-
await ng('e2e', 'test-project');
57+
await ng('e2e', '--port=0', 'test-project');
5858
}

tests/legacy-cli/e2e/tests/build/lazy-load-syntax.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,6 @@ export default async function () {
9898
// Both Ivy and View Engine should support it.
9999
await replaceLoadChildren(`() => import('./lazy/lazy.module').then(m => m.LazyModule)`);
100100

101-
await ng('e2e');
102-
await ng('e2e', '--configuration=production');
101+
await ng('e2e', '--port=0');
102+
await ng('e2e', '--port=0', '--configuration=production');
103103
}

tests/legacy-cli/e2e/tests/build/library/lib-consumption-full-aot.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export default async function () {
88
await ng('build', 'my-lib', '--configuration=development');
99

1010
// Check that the e2e succeeds prod and non prod mode
11-
await ng('e2e', '--configuration=production');
12-
await ng('e2e', '--configuration=development');
11+
await ng('e2e', '--port=0', '--configuration=production');
12+
await ng('e2e', '--port=0', '--configuration=development');
1313
}

tests/legacy-cli/e2e/tests/build/library/lib-consumption-full-jit.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export default async function () {
1717
});
1818

1919
// Check that the e2e succeeds prod and non prod mode
20-
await ng('e2e', '--configuration=production');
21-
await ng('e2e', '--configuration=development');
20+
await ng('e2e', '--port=0', '--configuration=production');
21+
await ng('e2e', '--port=0', '--configuration=development');
2222

2323
// Validate that sourcemaps for the library exists.
2424
await ng('build', '--configuration=development');

tests/legacy-cli/e2e/tests/build/library/lib-consumption-partial-aot.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export default async function () {
88
await ng('build', 'my-lib', '--configuration=production');
99

1010
// Check that the e2e succeeds prod and non prod mode
11-
await ng('e2e', '--configuration=production');
12-
await ng('e2e', '--configuration=development');
11+
await ng('e2e', '--port=0', '--configuration=production');
12+
await ng('e2e', '--port=0', '--configuration=development');
1313
}

tests/legacy-cli/e2e/tests/build/library/lib-consumption-partial-jit.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ export default async function () {
1616
});
1717

1818
// Check that the e2e succeeds prod and non prod mode
19-
await ng('e2e', '--configuration=production');
20-
await ng('e2e', '--configuration=development');
19+
await ng('e2e', '--port=0', '--configuration=production');
20+
await ng('e2e', '--port=0', '--configuration=development');
2121
}

tests/legacy-cli/e2e/tests/build/material.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,5 @@ export default async function () {
7777
`,
7878
);
7979

80-
await ng('e2e', '--configuration=production');
80+
await ng('e2e', '--port=0', '--configuration=production');
8181
}

tests/legacy-cli/e2e/tests/build/worker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ export default async function () {
5151
`,
5252
);
5353

54-
await ng('e2e');
54+
await ng('e2e', '--port=0');
5555
}

tests/legacy-cli/e2e/tests/commands/e2e/e2e-and-serve.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default async function () {
55
try {
66
// Should run side-by-side with `ng serve`
77
await ngServe();
8-
await silentNg('e2e');
8+
await silentNg('e2e', '--port=0');
99
} finally {
1010
killAllProcesses();
1111
}

tests/legacy-cli/e2e/tests/commands/e2e/multiple-specs.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default async function () {
88

99
await silentNg(
1010
'e2e',
11+
'--port=0',
1112
'test-project',
1213
'--specs',
1314
'./e2e/renamed-app.e2e-spec.ts',

tests/legacy-cli/e2e/tests/commands/e2e/protractor-config.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@ import { silentNg } from '../../../utils/process';
44
export default async function () {
55
// Should accept different config file
66
await moveFile('./e2e/protractor.conf.js', './e2e/renamed-protractor.conf.js');
7-
await silentNg('e2e', 'test-project', '--protractor-config=e2e/renamed-protractor.conf.js');
7+
await silentNg(
8+
'e2e',
9+
'--port=0',
10+
'test-project',
11+
'--protractor-config=e2e/renamed-protractor.conf.js',
12+
);
813
}

tests/legacy-cli/e2e/tests/commands/e2e/suite.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ export default async function () {
1212
},
1313
`,
1414
);
15-
await silentNg('e2e', 'test-project', '--suite=app');
15+
await silentNg('e2e', '--port=0', 'test-project', '--suite=app');
1616
}

tests/legacy-cli/e2e/tests/i18n/ivy-localize-es2015-e2e.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ export default async function () {
77

88
for (const { lang } of langTranslations) {
99
// Execute Application E2E tests with dev server
10-
await ng('e2e', `--configuration=${lang}`, '--port=0');
10+
await ng('e2e', '--port=0', `--configuration=${lang}`, '--port=0');
1111
}
1212
}

tests/legacy-cli/e2e/tests/i18n/ivy-localize-locale-data-augment.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ export default async function () {
4040
await expectFileToMatch(`${outputPath}/vendor.js`, lang);
4141

4242
// Execute Application E2E tests with dev server
43-
await ng('e2e', `--configuration=${lang}`, '--port=0');
43+
await ng('e2e', '--port=0', `--configuration=${lang}`);
4444
}
4545
}

tests/legacy-cli/e2e/tests/misc/browsers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export default async function () {
4646
// Execute application's E2E tests with SauceLabs
4747
await ng(
4848
'e2e',
49+
'--port=0',
4950
'test-project',
5051
'--protractor-config=e2e/protractor-saucelabs.conf.js',
5152
'--dev-server-target=',

tests/legacy-cli/e2e/tests/misc/e2e-host.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ export default async function () {
1919
appArchitect.serve.options.host = host;
2020
});
2121

22-
await ng('e2e');
23-
await ng('e2e', '--host', host);
22+
await ng('e2e', '--port=0');
23+
await ng('e2e', '--port=0', '--host', host);
2424
}

tests/legacy-cli/e2e/tests/misc/http-headers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default async function () {
2626

2727
let errorMessage: string | null = null;
2828
try {
29-
await ng('e2e');
29+
await ng('e2e', '--port=0');
3030
} catch (error) {
3131
errorMessage = error instanceof Error ? error.message : null;
3232
}

tests/legacy-cli/e2e/tests/misc/third-party-decorators.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,5 @@ export default async function () {
165165
});
166166

167167
// Run the e2e tests against a production build.
168-
await ng('e2e', '--configuration=production');
168+
await ng('e2e', '--port=0', '--configuration=production');
169169
}

tests/legacy-cli/e2e/tests/misc/trusted-types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default async function () {
6969
});
7070

7171
try {
72-
await ng('e2e');
72+
await ng('e2e', '--port=0');
7373
} catch (error) {
7474
console.error(`Test case AOT ${aot} with CSP header ${csp} failed.`);
7575
throw error;

tests/legacy-cli/e2e/tests/update/update.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ export default async function () {
7979
await ng('generate', 'component', 'my-comp');
8080
await ng('test', '--watch=false');
8181

82-
await ng('e2e');
83-
await ng('e2e', '--configuration=production');
82+
await ng('e2e', '--port=0');
83+
await ng('e2e', '--port=0', '--configuration=production');
8484

8585
// Verify project now creates bundles
8686
await noSilentNg('build', '--configuration=production');

0 commit comments

Comments
 (0)