Skip to content

Commit 2b8858f

Browse files
alan-agius4filipesilva
authored andcommitted
test(@angular-devkit/build-angular): add test to check build logs
(cherry picked from commit 4205452)
1 parent 8c2b852 commit 2b8858f

File tree

1 file changed

+30
-4
lines changed
  • tests/legacy-cli/e2e/tests/basic

1 file changed

+30
-4
lines changed

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

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expectFileToMatch } from '../../utils/fs';
1+
import { expectFileToMatch, replaceInFile } from '../../utils/fs';
22
import { ng } from '../../utils/process';
33

44

@@ -12,8 +12,34 @@ export default async function() {
1212
await ng('build', 'test-project', '--no-progress');
1313
await ng('build', '--no-progress', 'test-project');
1414

15+
// Enable Differential loading to run both size checks
16+
await replaceInFile(
17+
'.browserslistrc',
18+
'not IE 11',
19+
'IE 11',
20+
);
1521
// Production build
16-
await ng('build', '--prod');
17-
await expectFileToMatch('dist/test-project/index.html', /main\.[a-zA-Z0-9]{20}\.js/);
18-
await ng('build', '--prod', '--no-progress', 'test-project');
22+
const { stderr: stderrProgress } = await ng('build', '--prod', '--progress');
23+
await expectFileToMatch('dist/test-project/index.html', /main-es5\.[a-zA-Z0-9]{20}\.js/);
24+
await expectFileToMatch('dist/test-project/index.html', /main-es2015\.[a-zA-Z0-9]{20}\.js/);
25+
26+
const logs: string[] = [
27+
'Browser application bundle generation complete',
28+
'ES5 bundle generation complete',
29+
'Copying assets complete',
30+
'Index html generation complete',
31+
];
32+
33+
for (const log of logs) {
34+
if (!stderrProgress.includes(log)) {
35+
throw new Error(`Expected stderr to contain '${log}' but didn't.\n${stderrProgress}`);
36+
}
37+
}
38+
39+
const { stderr: stderrNoProgress } = await ng('build', '--prod', '--no-progress');
40+
for (const log of logs) {
41+
if (stderrNoProgress.includes(log)) {
42+
throw new Error(`Expected stderr not to contain '${log}' but it did.\n${stderrProgress}`);
43+
}
44+
}
1945
}

0 commit comments

Comments
 (0)