Skip to content

Commit c18a2ca

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 e77baea commit c18a2ca

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
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-yarn --glob="tests/basic/**" --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_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)