Skip to content

Commit 2c95ea7

Browse files
committed
test: couple of clean ups in e2e tests
Split tests and remove disabled tests
1 parent 0b7f5d3 commit 2c95ea7

37 files changed

+523
-796
lines changed

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

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,21 @@ import { ng } from '../../utils/process';
44

55
export default async function () {
66
// Development build
7-
const { stdout: stdoutDev } = await ng('build', '--configuration=development');
7+
const { stdout } = await ng('build', '--configuration=development');
88
await expectFileToMatch('dist/test-project/index.html', 'main.js');
9-
if (stdoutDev.includes('Estimated Transfer Size')) {
9+
10+
if (stdout.includes('Estimated Transfer Size')) {
1011
throw new Error(
11-
`Expected stdout not to contain 'Estimated Transfer Size' but it did.\n${stdoutDev}`,
12+
`Expected stdout not to contain 'Estimated Transfer Size' but it did.\n${stdout}`,
1213
);
1314
}
1415

15-
// Named Development build
16-
await ng('build', 'test-project', '--configuration=development');
17-
await ng('build', '--configuration=development', 'test-project', '--no-progress');
18-
await ng('build', '--configuration=development', '--no-progress', 'test-project');
19-
2016
// Production build
21-
const { stderr: stderrProgress, stdout } = await ng('build', '--progress');
17+
await ng('build');
2218
if (getGlobalVariable('argv')['esbuild']) {
2319
// esbuild uses an 8 character hash
2420
await expectFileToMatch('dist/test-project/index.html', /main\.[a-zA-Z0-9]{8}\.js/);
25-
26-
// EXPERIMENTAL_ESBUILD: esbuild does not yet output build stats
27-
return;
2821
} else {
2922
await expectFileToMatch('dist/test-project/index.html', /main\.[a-zA-Z0-9]{16}\.js/);
3023
}
31-
32-
if (!stdout.includes('Initial Total')) {
33-
throw new Error(`Expected stdout to contain 'Initial Total' but it did not.\n${stdout}`);
34-
}
35-
36-
if (!stdout.includes('Estimated Transfer Size')) {
37-
throw new Error(
38-
`Expected stdout to contain 'Estimated Transfer Size' but it did not.\n${stdout}`,
39-
);
40-
}
41-
42-
const logs: string[] = [
43-
'Browser application bundle generation complete',
44-
'Copying assets complete',
45-
'Index html generation complete',
46-
];
47-
48-
for (const log of logs) {
49-
if (!stderrProgress.includes(log)) {
50-
throw new Error(`Expected stderr to contain '${log}' but didn't.\n${stderrProgress}`);
51-
}
52-
}
53-
54-
const { stderr: stderrNoProgress } = await ng('build', '--no-progress');
55-
for (const log of logs) {
56-
if (stderrNoProgress.includes(log)) {
57-
throw new Error(`Expected stderr not to contain '${log}' but it did.\n${stderrProgress}`);
58-
}
59-
}
6024
}
Lines changed: 7 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,10 @@
1-
import { ng, execAndWaitForOutputToMatch, killAllProcesses } from '../../utils/process';
1+
import { silentNg } from '../../utils/process';
22
import { expectToFail } from '../../utils/utils';
3-
import { moveFile, copyFile, replaceInFile } from '../../utils/fs';
43

5-
export default function () {
6-
return (
7-
Promise.resolve()
8-
// Should fail without serving
9-
.then(() => expectToFail(() => ng('e2e', 'test-project', '--dev-server-target=')))
10-
// These should work.
11-
.then(() => ng('e2e', 'test-project'))
12-
.then(() => ng('e2e', 'test-project', '--dev-server-target=test-project:serve'))
13-
// Should accept different config file
14-
.then(() => moveFile('./e2e/protractor.conf.js', './e2e/renamed-protractor.conf.js'))
15-
.then(() => ng('e2e', 'test-project', '--protractor-config=e2e/renamed-protractor.conf.js'))
16-
.then(() => moveFile('./e2e/renamed-protractor.conf.js', './e2e/protractor.conf.js'))
17-
// Should accept different multiple spec files
18-
.then(() => moveFile('./e2e/src/app.e2e-spec.ts', './e2e/src/renamed-app.e2e-spec.ts'))
19-
.then(() =>
20-
copyFile('./e2e/src/renamed-app.e2e-spec.ts', './e2e/src/another-app.e2e-spec.ts'),
21-
)
22-
.then(() =>
23-
ng(
24-
'e2e',
25-
'test-project',
26-
'--specs',
27-
'./e2e/renamed-app.e2e-spec.ts',
28-
'--specs',
29-
'./e2e/another-app.e2e-spec.ts',
30-
),
31-
)
32-
// Rename the spec back to how it was.
33-
.then(() => moveFile('./e2e/src/renamed-app.e2e-spec.ts', './e2e/src/app.e2e-spec.ts'))
34-
// Suites block need to be added in the protractor.conf.js file to test suites
35-
.then(() =>
36-
replaceInFile(
37-
'e2e/protractor.conf.js',
38-
`allScriptsTimeout: 11000,`,
39-
`allScriptsTimeout: 11000,
40-
suites: {
41-
app: './e2e/src/app.e2e-spec.ts'
42-
},
43-
`,
44-
),
45-
)
46-
.then(() => ng('e2e', 'test-project', '--suite=app'))
47-
// Remove suites block from protractor.conf.js file after testing suites
48-
.then(() =>
49-
replaceInFile(
50-
'e2e/protractor.conf.js',
51-
`allScriptsTimeout: 11000,
52-
suites: {
53-
app: './e2e/src/app.e2e-spec.ts'
54-
},
55-
`,
56-
`allScriptsTimeout: 11000,`,
57-
),
58-
)
59-
// Should run side-by-side with `ng serve`
60-
.then(() => execAndWaitForOutputToMatch('ng', ['serve'], / Compiled successfully./))
61-
.then(() => ng('e2e', 'test-project', '--dev-server-target='))
62-
.finally(() => killAllProcesses())
63-
);
4+
export default async function () {
5+
await expectToFail(() => silentNg('e2e', 'test-project', '--dev-server-target='));
6+
7+
// These should work.
8+
await silentNg('e2e', 'test-project');
9+
await silentNg('e2e', 'test-project', '--dev-server-target=test-project:serve');
6410
}

0 commit comments

Comments
 (0)