Skip to content

Commit 6846024

Browse files
committed
test: change E2E to zoneless
The e2e tests reflect the new default behaviour.
1 parent 881e42d commit 6846024

23 files changed

+114
-108
lines changed

packages/angular_devkit/build_angular/src/builders/prerender/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ async function _renderUniversal(
168168
browserOptions.optimization,
169169
);
170170

171-
const zonePackage = require.resolve('zone.js', { paths: [context.workspaceRoot] });
171+
let zonePackage: string | undefined;
172+
try {
173+
zonePackage = require.resolve('zone.js/node', { paths: [context.workspaceRoot] });
174+
} catch {}
172175

173176
const { baseOutputPath = '' } = serverResult;
174177
const worker = new Piscina({

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default async function () {
2020
// Ensure local test registry is used when outside a project
2121
await setNPMConfigRegistry(true);
2222

23-
await ng('new', 'test-project', '--skip-install', '--no-zoneless');
23+
await ng('new', 'test-project', '--skip-install');
2424
await expectFileToExist(join(process.cwd(), 'test-project'));
2525
process.chdir('./test-project');
2626

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export default async function () {
5858
await expectFileToMatch(
5959
'dist/test-project/browser/index.html',
6060
[
61-
'<script src="polyfills.js" type="module"></script>',
6261
'<script src="scripts.js" defer></script>',
6362
'<script src="renamed-script.js" defer></script>',
6463
'<script src="main.js" type="module"></script>',
@@ -69,7 +68,6 @@ export default async function () {
6968
'dist/test-project/browser/index.html',
7069
[
7170
'<script src="runtime.js" type="module"></script>',
72-
'<script src="polyfills.js" type="module"></script>',
7371
'<script src="scripts.js" defer></script>',
7472
'<script src="renamed-script.js" defer></script>',
7573
'<script src="vendor.js" type="module"></script>',

tests/legacy-cli/e2e/tests/build/app-shell/app-shell-ngmodule.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,7 @@ import { updateJsonFile } from '../../../utils/project';
77
const snapshots = require('../../../ng-snapshot/package.json');
88

99
export default async function () {
10-
await ng(
11-
'generate',
12-
'app',
13-
'test-project-two',
14-
'--routing',
15-
'--no-standalone',
16-
'--skip-install',
17-
'--no-zoneless',
18-
);
10+
await ng('generate', 'app', 'test-project-two', '--routing', '--no-standalone', '--skip-install');
1911
await ng('generate', 'app-shell', '--project', 'test-project-two');
2012

2113
const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@ import { ng } from '../../utils/process';
33
import { updateJsonFile, useCIChrome, useCIDefaults } from '../../utils/project';
44

55
export default async function () {
6-
await ng(
7-
'generate',
8-
'app',
9-
'test-project-two',
10-
'--no-standalone',
11-
'--skip-install',
12-
'--no-zoneless',
13-
);
6+
await ng('generate', 'app', 'test-project-two', '--no-standalone', '--skip-install');
147
await ng('generate', 'private-e2e', '--related-app-name=test-project-two');
158

169
// Setup testing to use CI Chrome.

tests/legacy-cli/e2e/tests/build/prerender/http-requests-assets.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ng } from '../../../utils/process';
22
import { getGlobalVariable } from '../../../utils/env';
3-
import { expectFileToMatch, rimraf, writeMultipleFiles } from '../../../utils/fs';
4-
import { installWorkspacePackages } from '../../../utils/packages';
3+
import { expectFileToMatch, writeMultipleFiles } from '../../../utils/fs';
4+
import { installWorkspacePackages, uninstallPackage } from '../../../utils/packages';
55
import { useSha } from '../../../utils/project';
66

77
export default async function () {
@@ -11,16 +11,15 @@ export default async function () {
1111
return;
1212
}
1313

14-
// Forcibly remove in case another test doesn't clean itself up.
15-
await rimraf('node_modules/@angular/ssr');
16-
await ng('add', '@angular/ssr', '--skip-confirmation');
14+
await uninstallPackage('@angular/ssr');
15+
await ng('add', '@angular/ssr', '--skip-confirmation', '--skip-install');
1716
await useSha();
1817
await installWorkspacePackages();
1918

2019
await writeMultipleFiles({
2120
// Add http client and route
2221
'src/app/app.config.ts': `
23-
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
22+
import { ApplicationConfig } from '@angular/core';
2423
import { provideRouter } from '@angular/router';
2524
2625
import {Home} from './home/home';
@@ -35,7 +34,6 @@ export default async function () {
3534
}]),
3635
provideClientHydration(),
3736
provideHttpClient(withFetch()),
38-
provideZoneChangeDetection({ eventCoalescing: true }),
3937
],
4038
};
4139
`,
@@ -46,7 +44,7 @@ export default async function () {
4644

4745
// Update component to do an HTTP call to asset.
4846
'src/app/app.ts': `
49-
import { Component, inject } from '@angular/core';
47+
import { ChangeDetectorRef, Component, inject } from '@angular/core';
5048
import { CommonModule } from '@angular/common';
5149
import { RouterOutlet } from '@angular/router';
5250
import { HttpClient } from '@angular/common/http';
@@ -64,15 +62,18 @@ export default async function () {
6462
export class App {
6563
data: any;
6664
dataWithSpace: any;
65+
private readonly cdr: ChangeDetectorRef = inject(ChangeDetectorRef);
6766
6867
constructor() {
6968
const http = inject(HttpClient);
7069
http.get('/media.json').subscribe((d) => {
7170
this.data = d;
71+
this.cdr.markForCheck();
7272
});
7373
7474
http.get('/media%20with-space.json').subscribe((d) => {
7575
this.dataWithSpace = d;
76+
this.cdr.markForCheck();
7677
});
7778
}
7879
}

tests/legacy-cli/e2e/tests/build/server-rendering/express-engine-ngmodule.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,7 @@ export default async function () {
1515
// forcibly remove in case another test doesn't clean itself up
1616
await rimraf('node_modules/@angular/ssr');
1717

18-
await ng(
19-
'generate',
20-
'app',
21-
'test-project-two',
22-
'--no-standalone',
23-
'--skip-install',
24-
'--no-zoneless',
25-
);
18+
await ng('generate', 'app', 'test-project-two', '--no-standalone', '--skip-install');
2619
await ng('generate', 'private-e2e', '--related-app-name=test-project-two');
2720

2821
// Setup testing to use CI Chrome.

tests/legacy-cli/e2e/tests/build/server-rendering/server-routes-output-mode-static-http-calls.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default async function () {
2222
'public/media.json': JSON.stringify({ dataFromAssets: true }),
2323
// Update component to do an HTTP call to asset and API.
2424
'src/app/app.ts': `
25-
import { Component, inject } from '@angular/core';
25+
import { ChangeDetectorRef, Component, inject } from '@angular/core';
2626
import { JsonPipe } from '@angular/common';
2727
import { RouterOutlet } from '@angular/router';
2828
import { HttpClient } from '@angular/common/http';
@@ -40,23 +40,26 @@ export default async function () {
4040
export class App {
4141
assetsData: any;
4242
apiData: any;
43+
private readonly cdr: ChangeDetectorRef = inject(ChangeDetectorRef);
4344
4445
constructor() {
4546
const http = inject(HttpClient);
4647
4748
http.get('/media.json').toPromise().then((d) => {
4849
this.assetsData = d;
50+
this.cdr.markForCheck();
4951
});
5052
5153
http.get('/api').toPromise().then((d) => {
5254
this.apiData = d;
55+
this.cdr.markForCheck();
5356
});
5457
}
5558
}
5659
`,
5760
// Add http client and route
5861
'src/app/app.config.ts': `
59-
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
62+
import { ApplicationConfig } from '@angular/core';
6063
import { provideRouter } from '@angular/router';
6164
6265
import { Home } from './home/home';
@@ -71,7 +74,6 @@ export default async function () {
7174
}]),
7275
provideClientHydration(),
7376
provideHttpClient(withFetch()),
74-
provideZoneChangeDetection({ eventCoalescing: true }),
7577
],
7678
};
7779
`,

tests/legacy-cli/e2e/tests/build/server-rendering/server-routes-output-mode-static-i18n_APP_BASE_HREF.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { join } from 'node:path';
22
import { existsSync } from 'node:fs';
33
import assert from 'node:assert';
4-
import { expectFileNotToExist, expectFileToMatch, writeFile } from '../../../utils/fs';
4+
import { expectFileToMatch, writeFile } from '../../../utils/fs';
55
import { ng, noSilentNg, silentNg } from '../../../utils/process';
66
import { installWorkspacePackages, uninstallPackage } from '../../../utils/packages';
77
import { useSha } from '../../../utils/project';
@@ -66,7 +66,7 @@ export default async function () {
6666
await writeFile(
6767
'src/app/app.config.ts',
6868
`
69-
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
69+
import { ApplicationConfig } from '@angular/core';
7070
import { provideRouter } from '@angular/router';
7171
7272
import { routes } from './app.routes';
@@ -75,7 +75,6 @@ export default async function () {
7575
7676
export const appConfig: ApplicationConfig = {
7777
providers: [
78-
provideZoneChangeDetection({ eventCoalescing: true }),
7978
provideRouter(routes),
8079
provideClientHydration(),
8180
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export default async function () {
1212
await ng('build', '--output-hashing=bundles', '--source-map', '--configuration=development');
1313

1414
await ng('build', '--output-hashing=none', '--source-map');
15-
await testForSourceMaps(useWebpackBuilder ? 3 : 2);
15+
await testForSourceMaps(useWebpackBuilder ? 2 : 1);
1616

1717
await ng('build', '--output-hashing=none', '--source-map', '--configuration=development');
18-
await testForSourceMaps(useWebpackBuilder ? 4 : 2);
18+
await testForSourceMaps(useWebpackBuilder ? 3 : 1);
1919
}
2020

2121
async function testForSourceMaps(expectedNumberOfFiles: number): Promise<void> {

0 commit comments

Comments
 (0)