Skip to content

Commit 9add714

Browse files
AndrewKushnirthePunderWoman
authored andcommitted
refactor(core): remove deprecated aotSummaries fields in TestBed config (angular#45487)
BREAKING CHANGE: Since Ivy, TestBed doesn't use AOT summaries. The `aotSummaries` fields in TestBed APIs were present, but unused. The fields were deprecated in previous major version and in v14 those fields are removed. The `aotSummaries` fields were completely unused, so you can just drop them from the TestBed APIs usage. PR Close angular#45487
1 parent 89ed8d8 commit 9add714

File tree

6 files changed

+6
-63
lines changed

6 files changed

+6
-63
lines changed

aio/content/guide/deprecations.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ v14 - v17
7474
| `@angular/core` | [Factory-based signature of `ViewContainerRef.createComponent`](api/core/ViewContainerRef#createComponent) | <!-- v13 --> v15 |
7575
| `@angular/core/testing` | [`TestBed.get`](#testing) | <!-- v9 --> v12 |
7676
| `@angular/core/testing` | [`async`](#testing) | <!-- v9 --> v12 |
77-
| `@angular/core/testing` | [`aotSummaries` argument in `TestBed.initTestEnvironment`](#testing) | <!-- v13 --> v14 |
78-
| `@angular/core/testing` | [`aotSummaries` field of the `TestModuleMetadata` type](#testing) | <!-- v13 --> v14 |
7977
| `@angular/forms` | [`FormBuilder.group` legacy options parameter](api/forms/FormBuilder#group) | <!-- v11 --> v14 |
8078
| `@angular/platform-server` | [`renderModuleFactory`](#platform-server) | <!-- v13 --> v15 |
8179
| `@angular/router` | [`relativeLinkResolution`](#relativeLinkResolution) | <!-- v14 --> v16 |
@@ -148,8 +146,6 @@ In the [API reference section](api) of this site, deprecated APIs are indicated
148146
|:--- |:--- |:--- |:--- |
149147
| [`TestBed.get`](api/core/testing/TestBed#get) | [`TestBed.inject`](api/core/testing/TestBed#inject) | v9 | Same behavior, but type safe. |
150148
| [`async`](api/core/testing/async) | [`waitForAsync`](api/core/testing/waitForAsync) | v10 | Same behavior, but rename to avoid confusion. |
151-
| [`aotSummaries` argument in `TestBed.initTestEnvironment`](api/core/testing/TestBed#inittestenvironment) | No replacement needed | v13 | Summary files are unused in Ivy. |
152-
| [`aotSummaries` field of the `TestModuleMetadata` type](api/core/testing/TestModuleMetadata) | No replacement needed | v13 | Summary files are unused in Ivy. |
153149

154150
<a id="platform-browser-dynamic"></a>
155151

aio/tests/e2e/src/api-pages.e2e-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ describe('Api pages', () => {
7979

8080
it('should show all overloads of interface methods', async () => {
8181
await page.navigateTo('api/core/testing/TestBedStatic');
82-
expect(await (await page.getInstanceMethodOverloads('initTestEnvironment')).length).toEqual(2);
82+
expect(await (await page.getInstanceMethodOverloads('inject')).length).toEqual(2);
8383
});
8484

8585
it('should show all overloads of pseudo-class methods', async () => {
8686
await page.navigateTo('api/core/testing/TestBed');
87-
expect(await (await page.getInstanceMethodOverloads('initTestEnvironment')).length).toEqual(2);
87+
expect(await (await page.getInstanceMethodOverloads('inject')).length).toEqual(2);
8888
});
8989
});

goldens/public-api/core/testing/index.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ export interface TestBed {
114114
// @deprecated (undocumented)
115115
get(token: any, notFoundValue?: any): any;
116116
initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, options?: TestEnvironmentOptions): void;
117-
// @deprecated
118-
initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): void;
119117
// (undocumented)
120118
inject<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
121119
// (undocumented)
@@ -173,8 +171,6 @@ export interface TestBedStatic {
173171
// @deprecated (undocumented)
174172
get(token: any, notFoundValue?: any): any;
175173
initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, options?: TestEnvironmentOptions): TestBed;
176-
// @deprecated
177-
initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): TestBed;
178174
// (undocumented)
179175
inject<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
180176
// (undocumented)
@@ -219,8 +215,6 @@ export class TestComponentRenderer {
219215

220216
// @public (undocumented)
221217
export interface TestEnvironmentOptions {
222-
// @deprecated
223-
aotSummaries?: () => any[];
224218
teardown?: ModuleTeardownOptions;
225219
}
226220

@@ -230,7 +224,6 @@ export type TestModuleMetadata = {
230224
declarations?: any[];
231225
imports?: any[];
232226
schemas?: Array<SchemaMetadata | any[]>;
233-
aotSummaries?: () => any[];
234227
teardown?: ModuleTeardownOptions;
235228
};
236229

packages/core/testing/src/r3_test_bed.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ export class TestBedRender3 implements TestBed {
8080
*/
8181
static initTestEnvironment(
8282
ngModule: Type<any>|Type<any>[], platform: PlatformRef,
83-
summariesOrOptions?: TestEnvironmentOptions|(() => any[])): TestBed {
83+
options?: TestEnvironmentOptions): TestBed {
8484
const testBed = _getTestBedRender3();
85-
testBed.initTestEnvironment(ngModule, platform, summariesOrOptions);
85+
testBed.initTestEnvironment(ngModule, platform, options);
8686
return testBed;
8787
}
8888

@@ -230,15 +230,12 @@ export class TestBedRender3 implements TestBed {
230230
*/
231231
initTestEnvironment(
232232
ngModule: Type<any>|Type<any>[], platform: PlatformRef,
233-
summariesOrOptions?: TestEnvironmentOptions|(() => any[])): void {
233+
options?: TestEnvironmentOptions): void {
234234
if (this.platform || this.ngModule) {
235235
throw new Error('Cannot set base providers because it has already been called');
236236
}
237237

238-
// If `summariesOrOptions` is a function, it means that it's
239-
// an AOT summaries factory which Ivy doesn't support.
240-
TestBedRender3._environmentTeardownOptions =
241-
typeof summariesOrOptions === 'function' ? undefined : summariesOrOptions?.teardown;
238+
TestBedRender3._environmentTeardownOptions = options?.teardown;
242239

243240
this.platform = platform;
244241
this.ngModule = ngModule;

packages/core/testing/src/test_bed.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,6 @@ export interface TestBed {
3535
initTestEnvironment(
3636
ngModule: Type<any>|Type<any>[], platform: PlatformRef,
3737
options?: TestEnvironmentOptions): void;
38-
/**
39-
* Initialize the environment for testing with a compiler factory, a PlatformRef, and an
40-
* angular module. These are common to every test in the suite.
41-
*
42-
* This may only be called once, to set up the common providers for the current test
43-
* suite on the current platform. If you absolutely need to change the providers,
44-
* first use `resetTestEnvironment`.
45-
*
46-
* Test modules and platforms for individual platforms are available from
47-
* '@angular/<platform_name>/testing'.
48-
*
49-
* @deprecated This API that allows providing AOT summaries is deprecated, since summary files are
50-
* unused in Ivy.
51-
*/
52-
initTestEnvironment(
53-
ngModule: Type<any>|Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): void;
5438

5539
/**
5640
* Reset the providers for the test injector.

packages/core/testing/src/test_bed_common.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,13 @@ export type TestModuleMetadata = {
4444
declarations?: any[],
4545
imports?: any[],
4646
schemas?: Array<SchemaMetadata|any[]>,
47-
/**
48-
* @deprecated With Ivy, AOT summary files are unused.
49-
*/
50-
aotSummaries?: () => any[],
5147
teardown?: ModuleTeardownOptions;
5248
};
5349

5450
/**
5551
* @publicApi
5652
*/
5753
export interface TestEnvironmentOptions {
58-
/**
59-
* Provides a way to specify AOT summaries to use in TestBed.
60-
* This parameter is unused and deprecated in Ivy.
61-
*
62-
* @deprecated With Ivy, AOT summary files are unused.
63-
*/
64-
aotSummaries?: () => any[];
6554
/**
6655
* Configures the test module teardown behavior in `TestBed`.
6756
*/
@@ -102,22 +91,6 @@ export interface TestBedStatic {
10291
initTestEnvironment(
10392
ngModule: Type<any>|Type<any>[], platform: PlatformRef,
10493
options?: TestEnvironmentOptions): TestBed;
105-
/**
106-
* Initialize the environment for testing with a compiler factory, a PlatformRef, and an
107-
* angular module. These are common to every test in the suite.
108-
*
109-
* This may only be called once, to set up the common providers for the current test
110-
* suite on the current platform. If you absolutely need to change the providers,
111-
* first use `resetTestEnvironment`.
112-
*
113-
* Test modules and platforms for individual platforms are available from
114-
* '@angular/<platform_name>/testing'.
115-
*
116-
* @deprecated This API that allows providing AOT summaries is deprecated, since summary files are
117-
* unused in Ivy.
118-
*/
119-
initTestEnvironment(
120-
ngModule: Type<any>|Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): TestBed;
12194

12295
/**
12396
* Reset the providers for the test injector.

0 commit comments

Comments
 (0)