Skip to content

Commit

Permalink
test: use random devserver ports
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Jul 25, 2022
1 parent 6e8808e commit c74e33e
Show file tree
Hide file tree
Showing 25 changed files with 38 additions and 31 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
Expand Up @@ -23,7 +23,7 @@ exports.config = {
},
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
baseUrl: 'http://localhost:0/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
Expand Down
Expand Up @@ -14,7 +14,7 @@ exports.config = {
browserName: 'chrome',
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
baseUrl: 'http://localhost:0/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
Expand Down
Expand Up @@ -14,7 +14,7 @@ exports.config = {
browserName: 'chrome',
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
baseUrl: 'http://localhost:0/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy-cli/e2e/tests/basic/e2e.ts
Expand Up @@ -5,6 +5,6 @@ export default async function () {
await expectToFail(() => silentNg('e2e', 'test-project', '--dev-server-target='));

// These should work.
await silentNg('e2e', 'test-project');
await silentNg('e2e', 'test-project', '--dev-server-target=test-project:serve');
await silentNg('e2e', '--port=0', 'test-project');
await silentNg('e2e', '--port=0', 'test-project', '--dev-server-target=test-project:serve');
}
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e/tests/basic/standalone.ts
Expand Up @@ -54,5 +54,5 @@ export default async function () {
await ng('build');

// Perform the default E2E tests
await ng('e2e', 'test-project');
await ng('e2e', '--port=0', 'test-project');
}
4 changes: 2 additions & 2 deletions tests/legacy-cli/e2e/tests/build/lazy-load-syntax.ts
Expand Up @@ -98,6 +98,6 @@ export default async function () {
// Both Ivy and View Engine should support it.
await replaceLoadChildren(`() => import('./lazy/lazy.module').then(m => m.LazyModule)`);

await ng('e2e');
await ng('e2e', '--configuration=production');
await ng('e2e', '--port=0');
await ng('e2e', '--port=0', '--configuration=production');
}
Expand Up @@ -8,6 +8,6 @@ export default async function () {
await ng('build', 'my-lib', '--configuration=development');

// Check that the e2e succeeds prod and non prod mode
await ng('e2e', '--configuration=production');
await ng('e2e', '--configuration=development');
await ng('e2e', '--port=0', '--configuration=production');
await ng('e2e', '--port=0', '--configuration=development');
}
Expand Up @@ -17,8 +17,8 @@ export default async function () {
});

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

// Validate that sourcemaps for the library exists.
await ng('build', '--configuration=development');
Expand Down
Expand Up @@ -8,6 +8,6 @@ export default async function () {
await ng('build', 'my-lib', '--configuration=production');

// Check that the e2e succeeds prod and non prod mode
await ng('e2e', '--configuration=production');
await ng('e2e', '--configuration=development');
await ng('e2e', '--port=0', '--configuration=production');
await ng('e2e', '--port=0', '--configuration=development');
}
Expand Up @@ -16,6 +16,6 @@ export default async function () {
});

// Check that the e2e succeeds prod and non prod mode
await ng('e2e', '--configuration=production');
await ng('e2e', '--configuration=development');
await ng('e2e', '--port=0', '--configuration=production');
await ng('e2e', '--port=0', '--configuration=development');
}
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e/tests/build/material.ts
Expand Up @@ -77,5 +77,5 @@ export default async function () {
`,
);

await ng('e2e', '--configuration=production');
await ng('e2e', '--port=0', '--configuration=production');
}
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e/tests/build/worker.ts
Expand Up @@ -51,5 +51,5 @@ export default async function () {
`,
);

await ng('e2e');
await ng('e2e', '--port=0');
}
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e/tests/commands/e2e/e2e-and-serve.ts
Expand Up @@ -5,7 +5,7 @@ export default async function () {
try {
// Should run side-by-side with `ng serve`
await ngServe();
await silentNg('e2e');
await silentNg('e2e', '--port=0');
} finally {
killAllProcesses();
}
Expand Down
1 change: 1 addition & 0 deletions tests/legacy-cli/e2e/tests/commands/e2e/multiple-specs.ts
Expand Up @@ -8,6 +8,7 @@ export default async function () {

await silentNg(
'e2e',
'--port=0',
'test-project',
'--specs',
'./e2e/renamed-app.e2e-spec.ts',
Expand Down
7 changes: 6 additions & 1 deletion tests/legacy-cli/e2e/tests/commands/e2e/protractor-config.ts
Expand Up @@ -4,5 +4,10 @@ import { silentNg } from '../../../utils/process';
export default async function () {
// Should accept different config file
await moveFile('./e2e/protractor.conf.js', './e2e/renamed-protractor.conf.js');
await silentNg('e2e', 'test-project', '--protractor-config=e2e/renamed-protractor.conf.js');
await silentNg(
'e2e',
'--port=0',
'test-project',
'--protractor-config=e2e/renamed-protractor.conf.js',
);
}
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e/tests/commands/e2e/suite.ts
Expand Up @@ -12,5 +12,5 @@ export default async function () {
},
`,
);
await silentNg('e2e', 'test-project', '--suite=app');
await silentNg('e2e', '--port=0', 'test-project', '--suite=app');
}
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e/tests/i18n/ivy-localize-es2015-e2e.ts
Expand Up @@ -7,6 +7,6 @@ export default async function () {

for (const { lang } of langTranslations) {
// Execute Application E2E tests with dev server
await ng('e2e', `--configuration=${lang}`, '--port=0');
await ng('e2e', '--port=0', `--configuration=${lang}`, '--port=0');
}
}
Expand Up @@ -40,6 +40,6 @@ export default async function () {
await expectFileToMatch(`${outputPath}/vendor.js`, lang);

// Execute Application E2E tests with dev server
await ng('e2e', `--configuration=${lang}`, '--port=0');
await ng('e2e', '--port=0', `--configuration=${lang}`);
}
}
1 change: 1 addition & 0 deletions tests/legacy-cli/e2e/tests/misc/browsers.ts
Expand Up @@ -46,6 +46,7 @@ export default async function () {
// Execute application's E2E tests with SauceLabs
await ng(
'e2e',
'--port=0',
'test-project',
'--protractor-config=e2e/protractor-saucelabs.conf.js',
'--dev-server-target=',
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy-cli/e2e/tests/misc/e2e-host.ts
Expand Up @@ -19,6 +19,6 @@ export default async function () {
appArchitect.serve.options.host = host;
});

await ng('e2e');
await ng('e2e', '--host', host);
await ng('e2e', '--port=0');
await ng('e2e', '--port=0', '--host', host);
}
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e/tests/misc/http-headers.ts
Expand Up @@ -26,7 +26,7 @@ export default async function () {

let errorMessage: string | null = null;
try {
await ng('e2e');
await ng('e2e', '--port=0');
} catch (error) {
errorMessage = error instanceof Error ? error.message : null;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e/tests/misc/third-party-decorators.ts
Expand Up @@ -165,5 +165,5 @@ export default async function () {
});

// Run the e2e tests against a production build.
await ng('e2e', '--configuration=production');
await ng('e2e', '--port=0', '--configuration=production');
}
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e/tests/misc/trusted-types.ts
Expand Up @@ -69,7 +69,7 @@ export default async function () {
});

try {
await ng('e2e');
await ng('e2e', '--port=0');
} catch (error) {
console.error(`Test case AOT ${aot} with CSP header ${csp} failed.`);
throw error;
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy-cli/e2e/tests/update/update.ts
Expand Up @@ -79,8 +79,8 @@ export default async function () {
await ng('generate', 'component', 'my-comp');
await ng('test', '--watch=false');

await ng('e2e');
await ng('e2e', '--configuration=production');
await ng('e2e', '--port=0');
await ng('e2e', '--port=0', '--configuration=production');

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

0 comments on commit c74e33e

Please sign in to comment.