Skip to content

Commit f38d8df

Browse files
committed
test: prepare E2E tests for @angular/build project default
The E2E test setup and several of the individual E2E tests have been updated to be more robust for when the `@angular/build` package is used as the new default. The main changes involve ensuring that the Webpack- based `browser` builder testing uses the correct builders instead of the new `@angular/build` variants. This change also improves the reliability of some tests (e.g., `commands/add/version-specifier`) by not relying on outdated versions of Angular packages.
1 parent 33aef48 commit f38d8df

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ export default async function () {
4343
namedChunks: true,
4444
buildOptimizer: false,
4545
};
46+
47+
const serve = json['projects']['test-project']['architect']['serve'];
48+
serve.builder = '@angular-devkit/build-angular:dev-server';
49+
50+
const extract = json['projects']['test-project']['architect']['extract-i18n'];
51+
if (extract) {
52+
extract.builder = '@angular-devkit/build-angular:extract-i18n';
53+
}
54+
55+
const test = json['projects']['test-project']['architect']['test'];
56+
test.builder = '@angular-devkit/build-angular:karma';
4657
});
4758
await updateJsonFile('tsconfig.json', (tsconfig) => {
4859
delete tsconfig.compilerOptions.esModuleInterop;

tests/legacy-cli/e2e/tests/build/jit-ngmodule.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ export default async function () {
3939
};
4040

4141
build.options.aot = false;
42+
43+
const serve = json['projects']['test-project-two']['architect']['serve'];
44+
serve.builder = '@angular-devkit/build-angular:dev-server';
4245
});
4346
// Test it works
4447
await ng('e2e', 'test-project-two', '--configuration=production');

tests/legacy-cli/e2e/tests/build/rebuild-dot-dirname.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export default async function () {
4141
namedChunks: true,
4242
buildOptimizer: false,
4343
};
44+
45+
const serve = json['projects']['subdirectory-test-project']['architect']['serve'];
46+
serve.builder = '@angular-devkit/build-angular:dev-server';
4447
});
4548
}
4649

tests/legacy-cli/e2e/tests/commands/add/version-specifier.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default async function () {
1515
await appendFile('.npmrc', '\nforce=true\n');
1616
}
1717

18-
const tag = (await isPrereleaseCli()) ? '@next' : '';
18+
const tag = isPrereleaseCli() ? '@next' : '';
1919

2020
await ng('add', `@angular/localize${tag}`, '--skip-confirmation');
2121
await expectFileToMatch('package.json', /@angular\/localize/);
@@ -30,13 +30,12 @@ export default async function () {
3030
throw new Error('Installation should not have been skipped');
3131
}
3232

33-
// v12.2.0 has a package.json engine field that supports Node.js v16+
34-
const output3 = await ng('add', '@angular/[email protected]', '--skip-confirmation');
33+
const output3 = await ng('add', '@angular/[email protected]', '--skip-confirmation');
3534
if (output3.stdout.includes('Skipping installation: Package already installed')) {
3635
throw new Error('Installation should not have been skipped');
3736
}
3837

39-
const output4 = await ng('add', '@angular/localize@12', '--skip-confirmation');
38+
const output4 = await ng('add', '@angular/localize@19', '--skip-confirmation');
4039
if (!output4.stdout.includes('Skipping installation: Package already installed')) {
4140
throw new Error('Installation was not skipped');
4241
}

tests/legacy-cli/e2e/tests/test/test-environment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export default function () {
3333
production: {
3434
fileReplacements: [
3535
{
36-
src: 'src/environment.ts',
37-
replaceWith: 'src/environment.prod.ts',
36+
replace: 'src/environment.ts',
37+
with: 'src/environment.prod.ts',
3838
},
3939
],
4040
},

0 commit comments

Comments
 (0)