Skip to content

Commit

Permalink
test: use random e2e test ports (#23541)
Browse files Browse the repository at this point in the history
* test: use random e2e test ports

* test: use random ng serve ports
  • Loading branch information
jbedard committed Jul 28, 2022
1 parent acd5ad5 commit 35c4357
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Expand Up @@ -34,7 +34,7 @@ describe('Dev Server Builder', () => {
expect(output.success).toBe(true);

// When webpack-dev-server doesn't have `contentBase: false`, this will serve the repo README.
const response = await fetch('http://localhost:4200/README.md', {
const response = await fetch(`http://localhost:${output.port}/README.md`, {
headers: {
'Accept': 'text/html',
},
Expand Down
10 changes: 9 additions & 1 deletion tests/legacy-cli/e2e/utils/project.ts
Expand Up @@ -165,9 +165,17 @@ export function useCIDefaults(projectName = 'test-project') {
const appTargets = project.targets || project.architect;
appTargets.build.options.progress = false;
appTargets.test.options.progress = false;
// Disable auto-updating webdriver in e2e.
if (appTargets.e2e) {
// Disable auto-updating webdriver in e2e.
appTargets.e2e.options.webdriverUpdate = false;
// Use a random port in e2e.
appTargets.e2e.options.port = 0;
}

if (appTargets.serve) {
// Use a random port in serve.
appTargets.serve.options ??= {};
appTargets.serve.options.port = 0;
}
});
}
Expand Down

0 comments on commit 35c4357

Please sign in to comment.