Skip to content

Commit 6023adf

Browse files
clydinangular-robot[bot]
authored andcommitted
test(@angular-devkit/build-angular): execute all basic E2E tests with esbuild builder
With the increased feature parity of the esbuild-based browser application builder, all the basic E2E tests can now be executed against the builder. Several of the output checks were required to be updated to reflect the differences in console output, lazy chunk file naming, and less required initial files in the index HTML.
1 parent 8c4a84d commit 6023adf

File tree

5 files changed

+36
-26
lines changed

5 files changed

+36
-26
lines changed

tests/legacy-cli/e2e.bzl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ ESBUILD_TESTS = [
4141

4242
# Tests excluded for esbuild
4343
ESBUILD_IGNORE_TESTS = [
44-
"tests/basic/environment.js",
45-
"tests/basic/rebuild.js",
46-
"tests/basic/serve.js",
47-
"tests/basic/scripts-array.js",
4844
]
4945

5046
def _to_glob(patterns):

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ import { waitForAnyProcessOutputToMatch, silentNg } from '../../utils/process';
22
import { writeFile, writeMultipleFiles } from '../../utils/fs';
33
import fetch from 'node-fetch';
44
import { ngServe } from '../../utils/project';
5-
6-
const validBundleRegEx = / Compiled successfully./;
5+
import { getGlobalVariable } from '../../utils/env';
76

87
export default async function () {
8+
const esbuild = getGlobalVariable('argv')['esbuild'];
9+
const validBundleRegEx = esbuild ? /Complete\./ : /Compiled successfully\./;
10+
const lazyBundleRegEx = esbuild ? /lazy\.module/ : /lazy_module_ts\.js/;
11+
912
const port = await ngServe();
1013
// Add a lazy module.
1114
await silentNg('generate', 'module', 'lazy', '--routing');
@@ -15,7 +18,7 @@ export default async function () {
1518
// the file, otherwise rebuilds can be too fast and fail CI.
1619
// Count the bundles.
1720
await Promise.all([
18-
waitForAnyProcessOutputToMatch(/lazy_module_ts\.js/),
21+
waitForAnyProcessOutputToMatch(lazyBundleRegEx),
1922
writeFile(
2023
'src/app/app.module.ts',
2124
`

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

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getGlobalVariable } from '../../utils/env';
12
import { appendToFile, expectFileToMatch, writeMultipleFiles } from '../../utils/fs';
23
import { ng } from '../../utils/process';
34
import { updateJsonFile } from '../../utils/project';
@@ -50,15 +51,27 @@ export default async function () {
5051
await expectFileToMatch('dist/test-project/renamed-lazy-script.js', 'pre-rename-lazy-script');
5152

5253
// index.html lists the right bundles
53-
await expectFileToMatch(
54-
'dist/test-project/index.html',
55-
[
56-
'<script src="runtime.js" type="module"></script>',
57-
'<script src="polyfills.js" type="module"></script>',
58-
'<script src="scripts.js" defer></script>',
59-
'<script src="renamed-script.js" defer></script>',
60-
'<script src="vendor.js" type="module"></script>',
61-
'<script src="main.js" type="module"></script>',
62-
].join(''),
63-
);
54+
if (getGlobalVariable('argv')['esbuild']) {
55+
await expectFileToMatch(
56+
'dist/test-project/index.html',
57+
[
58+
'<script src="polyfills.js" type="module"></script>',
59+
'<script src="scripts.js" defer></script>',
60+
'<script src="renamed-script.js" defer></script>',
61+
'<script src="main.js" type="module"></script>',
62+
].join(''),
63+
);
64+
} else {
65+
await expectFileToMatch(
66+
'dist/test-project/index.html',
67+
[
68+
'<script src="runtime.js" type="module"></script>',
69+
'<script src="polyfills.js" type="module"></script>',
70+
'<script src="scripts.js" defer></script>',
71+
'<script src="renamed-script.js" defer></script>',
72+
'<script src="vendor.js" type="module"></script>',
73+
'<script src="main.js" type="module"></script>',
74+
].join(''),
75+
);
76+
}
6477
}

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { getGlobalVariable } from '../../utils/env';
21
import { expectFileToMatch, writeMultipleFiles } from '../../utils/fs';
32
import { ng } from '../../utils/process';
43
import { updateJsonFile } from '../../utils/project';
@@ -39,13 +38,9 @@ export default async function () {
3938
'<link rel="stylesheet" href="styles.css"><link rel="stylesheet" href="renamed-style.css">',
4039
);
4140

42-
if (getGlobalVariable('argv')['esbuild']) {
43-
// EXPERIMENTAL_ESBUILD: esbuild does not yet output build stats
44-
return;
45-
}
46-
4741
// Non injected styles should be listed under lazy chunk files
48-
if (!/Lazy Chunk Files.*\srenamed-lazy-style\.css/m.test(stdout)) {
42+
if (!/Lazy Chunk Files[\s\S]+renamed-lazy-style\.css/m.test(stdout)) {
43+
console.log(stdout);
4944
throw new Error(`Expected "renamed-lazy-style.css" to be listed under "Lazy Chunk Files".`);
5045
}
5146
}

tests/legacy-cli/e2e/utils/project.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ export function updateTsConfig(fn: (json: any) => any | void) {
2626
export async function ngServe(...args: string[]) {
2727
const port = await findFreePort();
2828

29+
const esbuild = getGlobalVariable('argv')['esbuild'];
30+
const validBundleRegEx = esbuild ? /Complete\./ : /Compiled successfully\./;
31+
2932
await execAndWaitForOutputToMatch(
3033
'ng',
3134
['serve', '--port', String(port), ...args],
32-
/ Compiled successfully./,
35+
validBundleRegEx,
3336
);
3437

3538
return port;

0 commit comments

Comments
 (0)