Skip to content

Commit

Permalink
refactor(core): remove deprecated aotSummaries fields in TestBed co…
Browse files Browse the repository at this point in the history
…nfig

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.
  • Loading branch information
AndrewKushnir committed Mar 31, 2022
1 parent 2b12959 commit 4c9b1ef
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 61 deletions.
4 changes: 0 additions & 4 deletions aio/content/guide/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ v14 -> v17
| `@angular/core` | [Factory-based signature of `ViewContainerRef.createComponent`](api/core/ViewContainerRef#createComponent) | <!--v13--> v15 |
| `@angular/core/testing` | [`TestBed.get`](#testing) | <!--v9--> v12 |
| `@angular/core/testing` | [`async`](#testing) | <!--v9--> v12 |
| `@angular/core/testing` | [`aotSummaries` argument in `TestBed.initTestEnvironment`](#testing) | <!--v13--> v14 |
| `@angular/core/testing` | [`aotSummaries` field of the `TestModuleMetadata` type](#testing) | <!--v13--> v14 |
| `@angular/forms` | [`FormBuilder.group` legacy options parameter](api/forms/FormBuilder#group) | <!--v11--> v14 |
| `@angular/platform-server` | [`renderModuleFactory`](#platform-server) | <!--v13--> v15 |
| `@angular/service-worker` | [`SwUpdate#activated`](api/service-worker/SwUpdate#activated) | <!--v13--> v16 |
Expand Down Expand Up @@ -144,8 +142,6 @@ This section contains a complete list all of the currently-deprecated APIs, with
| :------------------------------------------------------------------------------------------------------- | :-------------------------------------------------- | :-------------------- | :-------------------------------------------- |
| [`TestBed.get`](api/core/testing/TestBed#get) | [`TestBed.inject`](api/core/testing/TestBed#inject) | v9 | Same behavior, but type safe. |
| [`async`](api/core/testing/async) | [`waitForAsync`](api/core/testing/waitForAsync) | v10 | Same behavior, but rename to avoid confusion. |
| [`aotSummaries` argument in `TestBed.initTestEnvironment`](api/core/testing/TestBed#inittestenvironment) | No replacement needed | v13 | Summary files are unused in Ivy. |
| [`aotSummaries` field of the `TestModuleMetadata` type](api/core/testing/TestModuleMetadata) | No replacement needed | v13 | Summary files are unused in Ivy. |

{@a platform-browser-dynamic}

Expand Down
7 changes: 0 additions & 7 deletions goldens/public-api/core/testing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ export interface TestBed {
// @deprecated (undocumented)
get(token: any, notFoundValue?: any): any;
initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, options?: TestEnvironmentOptions): void;
// @deprecated
initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): void;
// (undocumented)
inject<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
// (undocumented)
Expand Down Expand Up @@ -173,8 +171,6 @@ export interface TestBedStatic {
// @deprecated (undocumented)
get(token: any, notFoundValue?: any): any;
initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, options?: TestEnvironmentOptions): TestBed;
// @deprecated
initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): TestBed;
// (undocumented)
inject<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
// (undocumented)
Expand Down Expand Up @@ -219,8 +215,6 @@ export class TestComponentRenderer {

// @public (undocumented)
export interface TestEnvironmentOptions {
// @deprecated
aotSummaries?: () => any[];
teardown?: ModuleTeardownOptions;
}

Expand All @@ -230,7 +224,6 @@ export type TestModuleMetadata = {
declarations?: any[];
imports?: any[];
schemas?: Array<SchemaMetadata | any[]>;
aotSummaries?: () => any[];
teardown?: ModuleTeardownOptions;
};

Expand Down
11 changes: 4 additions & 7 deletions packages/core/testing/src/r3_test_bed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ export class TestBedRender3 implements TestBed {
*/
static initTestEnvironment(
ngModule: Type<any>|Type<any>[], platform: PlatformRef,
summariesOrOptions?: TestEnvironmentOptions|(() => any[])): TestBed {
options?: TestEnvironmentOptions): TestBed {
const testBed = _getTestBedRender3();
testBed.initTestEnvironment(ngModule, platform, summariesOrOptions);
testBed.initTestEnvironment(ngModule, platform, options);
return testBed;
}

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

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

this.platform = platform;
this.ngModule = ngModule;
Expand Down
16 changes: 0 additions & 16 deletions packages/core/testing/src/test_bed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,6 @@ export interface TestBed {
initTestEnvironment(
ngModule: Type<any>|Type<any>[], platform: PlatformRef,
options?: TestEnvironmentOptions): void;
/**
* Initialize the environment for testing with a compiler factory, a PlatformRef, and an
* angular module. These are common to every test in the suite.
*
* This may only be called once, to set up the common providers for the current test
* suite on the current platform. If you absolutely need to change the providers,
* first use `resetTestEnvironment`.
*
* Test modules and platforms for individual platforms are available from
* '@angular/<platform_name>/testing'.
*
* @deprecated This API that allows providing AOT summaries is deprecated, since summary files are
* unused in Ivy.
*/
initTestEnvironment(
ngModule: Type<any>|Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): void;

/**
* Reset the providers for the test injector.
Expand Down
27 changes: 0 additions & 27 deletions packages/core/testing/src/test_bed_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,13 @@ export type TestModuleMetadata = {
declarations?: any[],
imports?: any[],
schemas?: Array<SchemaMetadata|any[]>,
/**
* @deprecated With Ivy, AOT summary files are unused.
*/
aotSummaries?: () => any[],
teardown?: ModuleTeardownOptions;
};

/**
* @publicApi
*/
export interface TestEnvironmentOptions {
/**
* Provides a way to specify AOT summaries to use in TestBed.
* This parameter is unused and deprecated in Ivy.
*
* @deprecated With Ivy, AOT summary files are unused.
*/
aotSummaries?: () => any[];
/**
* Configures the test module teardown behavior in `TestBed`.
*/
Expand Down Expand Up @@ -102,22 +91,6 @@ export interface TestBedStatic {
initTestEnvironment(
ngModule: Type<any>|Type<any>[], platform: PlatformRef,
options?: TestEnvironmentOptions): TestBed;
/**
* Initialize the environment for testing with a compiler factory, a PlatformRef, and an
* angular module. These are common to every test in the suite.
*
* This may only be called once, to set up the common providers for the current test
* suite on the current platform. If you absolutely need to change the providers,
* first use `resetTestEnvironment`.
*
* Test modules and platforms for individual platforms are available from
* '@angular/<platform_name>/testing'.
*
* @deprecated This API that allows providing AOT summaries is deprecated, since summary files are
* unused in Ivy.
*/
initTestEnvironment(
ngModule: Type<any>|Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): TestBed;

/**
* Reset the providers for the test injector.
Expand Down

0 comments on commit 4c9b1ef

Please sign in to comment.