Skip to content

Commit 9bb0f20

Browse files
committed
ci: add initial E2E test subset for experimental esbuild builder
The basic suite of E2E tests are now run against the newly introduced experimental esbuild-based builder (`browser-esbuild`). Several tests are currently ignored based on the current feature set of the builder.
1 parent df4fa9a commit 9bb0f20

File tree

6 files changed

+39
-6
lines changed

6 files changed

+39
-6
lines changed

.circleci/config.yml

+5
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ jobs:
218218
command: |
219219
mkdir /mnt/ramdisk/e2e-yarn
220220
node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} <<# parameters.snapshots >>--ng-snapshots<</ parameters.snapshots >> --yarn --tmpdir=/mnt/ramdisk/e2e-yarn --glob="{tests/basic/**,tests/update/**,tests/commands/add/**}"
221+
- run:
222+
name: Execute CLI E2E Tests Subset with esbuild builder
223+
command: |
224+
mkdir /mnt/ramdisk/e2e-esbuild
225+
node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} <<# parameters.snapshots >>--ng-snapshots<</ parameters.snapshots >> --esbuild --tmpdir=/mnt/ramdisk/e2e-esbuild --glob="{tests/basic/**,tests/build/prod-build.ts}" --ignore="tests/basic/{environment,rebuild,serve,scripts-array}.ts"
221226
- fail_fast
222227

223228
test-browsers:

tests/legacy-cli/e2e/setup/500-create-project.ts

+9
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ export default async function () {
3333
// Ensure local test registry is used inside a project
3434
await writeFile('.npmrc', `registry=${testRegistry}`);
3535
}
36+
37+
// Setup esbuild builder if requested on the commandline
38+
const useEsbuildBuilder = !!getGlobalVariable('argv')['esbuild'];
39+
if (useEsbuildBuilder) {
40+
await updateJsonFile('angular.json', (json) => {
41+
json['projects']['test-project']['architect']['build']['builder'] =
42+
'@angular-devkit/build-angular:browser-esbuild';
43+
});
44+
}
3645
}
3746

3847
await prepareProjectForE2e('test-project');

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getGlobalVariable } from '../../utils/env';
12
import { expectFileToMatch } from '../../utils/fs';
23
import { ng } from '../../utils/process';
34

@@ -18,7 +19,15 @@ export default async function () {
1819

1920
// Production build
2021
const { stderr: stderrProgress, stdout } = await ng('build', '--progress');
21-
await expectFileToMatch('dist/test-project/index.html', /main\.[a-zA-Z0-9]{16}\.js/);
22+
if (getGlobalVariable('argv')['esbuild']) {
23+
// esbuild uses an 8 character hash
24+
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;
28+
} else {
29+
await expectFileToMatch('dist/test-project/index.html', /main\.[a-zA-Z0-9]{16}\.js/);
30+
}
2231

2332
if (!stdout.includes('Initial Total')) {
2433
throw new Error(`Expected stdout to contain 'Initial Total' but it did not.\n${stdout}`);

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

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getGlobalVariable } from '../../utils/env';
12
import { expectFileToMatch, writeMultipleFiles } from '../../utils/fs';
23
import { ng } from '../../utils/process';
34
import { updateJsonFile } from '../../utils/project';
@@ -38,6 +39,11 @@ export default async function () {
3839
'<link rel="stylesheet" href="styles.css"><link rel="stylesheet" href="renamed-style.css">',
3940
);
4041

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

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

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { statSync } from 'fs';
22
import { join } from 'path';
3+
import { getGlobalVariable } from '../../utils/env';
34
import { expectFileToExist, expectFileToMatch, readFile } from '../../utils/fs';
45
import { noSilentNg } from '../../utils/process';
56

@@ -32,12 +33,15 @@ export default async function () {
3233
await noSilentNg('build');
3334
await expectFileToExist(join(process.cwd(), 'dist'));
3435
// Check for cache busting hash script src
35-
await expectFileToMatch('dist/test-project/index.html', /main\.[0-9a-f]{16}\.js/);
36-
await expectFileToMatch('dist/test-project/index.html', /styles\.[0-9a-f]{16}\.css/);
37-
await expectFileToMatch('dist/test-project/3rdpartylicenses.txt', /MIT/);
36+
await expectFileToMatch('dist/test-project/index.html', /main\.[0-9a-zA-Z]{8,16}\.js/);
37+
await expectFileToMatch('dist/test-project/index.html', /styles\.[0-9a-zA-Z]{8,16}\.css/);
38+
if (!getGlobalVariable('argv')['esbuild']) {
39+
// EXPERIMENTAL_ESBUILD: esbuild does not yet extract license text
40+
await expectFileToMatch('dist/test-project/3rdpartylicenses.txt', /MIT/);
41+
}
3842

3943
const indexContent = await readFile('dist/test-project/index.html');
40-
const mainPath = indexContent.match(/src="(main\.[a-z0-9]{0,32}\.js)"/)[1];
44+
const mainPath = indexContent.match(/src="(main\.[0-9a-zA-Z]{0,32}\.js)"/)[1];
4145

4246
// Content checks
4347
await expectFileToMatch(`dist/test-project/${mainPath}`, bootstrapRegExp);

tests/legacy-cli/e2e_runner.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Error.stackTraceLimit = Infinity;
3838
* If unnamed flags are passed in, the list of tests will be filtered to include only those passed.
3939
*/
4040
const argv = yargsParser(process.argv.slice(2), {
41-
boolean: ['debug', 'ng-snapshots', 'noglobal', 'nosilent', 'noproject', 'verbose'],
41+
boolean: ['debug', 'esbuild', 'ng-snapshots', 'noglobal', 'nosilent', 'noproject', 'verbose'],
4242
string: ['devkit', 'glob', 'ignore', 'reuse', 'ng-tag', 'tmpdir', 'ng-version'],
4343
configuration: {
4444
'dot-notation': false,

0 commit comments

Comments
 (0)