From 1f1103913a4ea454392a0d8f8eaa2493ba17e257 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Tue, 14 Aug 2018 16:27:04 -0700 Subject: [PATCH] refactor(ivy): cleanup the public API for core/testing (#25492) PR Close #25492 --- .../test/ng_package/core_package.spec.ts | 6 - packages/core/testing/src/r3_test_bed.ts | 56 ++++--- packages/core/testing/src/test_bed.ts | 137 +++++++++++++---- packages/core/testing/src/test_bed_common.ts | 98 +++++++++++- packages/core/testing/src/testing.ts | 5 +- .../testing/src/metadata_overrider.ts | 4 +- tools/public_api_guard/core/testing.d.ts | 145 +++--------------- 7 files changed, 260 insertions(+), 191 deletions(-) diff --git a/packages/bazel/test/ng_package/core_package.spec.ts b/packages/bazel/test/ng_package/core_package.spec.ts index 5950889318..9496201c5d 100644 --- a/packages/bazel/test/ng_package/core_package.spec.ts +++ b/packages/bazel/test/ng_package/core_package.spec.ts @@ -229,14 +229,8 @@ describe('@angular/core ng_package', () => { expect(shx.cat('testing.metadata.json')) .toContain(`"exports":[{"from":"./testing/testing"}],"flatModuleIndexRedirect":true`); }); - - it('should have an \'actual\' metadata.json file', () => { - expect(shx.cat('testing/testing.metadata.json')) - .toContain(`"metadata":{"async":{"__symbolic":"function"},`); - }); }); - describe('fesm2015', () => { it('should have a fesm15 file in the /fesm2015 directory', () => { expect(shx.cat('fesm2015/testing.js')).toContain(`export {`); }); diff --git a/packages/core/testing/src/r3_test_bed.ts b/packages/core/testing/src/r3_test_bed.ts index 2ae720fa84..6958f1bd28 100644 --- a/packages/core/testing/src/r3_test_bed.ts +++ b/packages/core/testing/src/r3_test_bed.ts @@ -11,7 +11,8 @@ import {Component, Directive, Injector, NgModule, Pipe, PlatformRef, Provider, R import {ComponentFixture} from './component_fixture'; import {MetadataOverride} from './metadata_override'; import {ComponentResolver, DirectiveResolver, NgModuleResolver, PipeResolver, Resolver} from './resolvers'; -import {ComponentFixtureAutoDetect, TestComponentRenderer, TestModuleMetadata} from './test_bed_common'; +import {TestBed} from './test_bed'; +import {ComponentFixtureAutoDetect, TestBedStatic, TestComponentRenderer, TestModuleMetadata} from './test_bed_common'; let _nextRootElementId = 0; @@ -25,7 +26,7 @@ let _nextRootElementId = 0; * Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3` * according to the compiler used. */ -export class TestBedRender3 { +export class TestBedRender3 implements Injector, 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. @@ -40,8 +41,7 @@ export class TestBedRender3 { * @experimental */ static initTestEnvironment( - ngModule: Type|Type[], platform: PlatformRef, - aotSummaries?: () => any[]): TestBedRender3 { + ngModule: Type|Type[], platform: PlatformRef, aotSummaries?: () => any[]): TestBed { const testBed = _getTestBedRender3(); testBed.initTestEnvironment(ngModule, platform, aotSummaries); return testBed; @@ -54,18 +54,18 @@ export class TestBedRender3 { */ static resetTestEnvironment(): void { _getTestBedRender3().resetTestEnvironment(); } - static configureCompiler(config: {providers?: any[]; useJit?: boolean;}): typeof TestBedRender3 { + static configureCompiler(config: {providers?: any[]; useJit?: boolean;}): TestBedStatic { _getTestBedRender3().configureCompiler(config); - return TestBedRender3; + return TestBedRender3 as any as TestBedStatic; } /** * Allows overriding default providers, directives, pipes, modules of the test injector, * which are defined in test_injector.js */ - static configureTestingModule(moduleDef: TestModuleMetadata): typeof TestBedRender3 { + static configureTestingModule(moduleDef: TestModuleMetadata): TestBedStatic { _getTestBedRender3().configureTestingModule(moduleDef); - return TestBedRender3; + return TestBedRender3 as any as TestBedStatic; } /** @@ -75,32 +75,31 @@ export class TestBedRender3 { */ static compileComponents(): Promise { return _getTestBedRender3().compileComponents(); } - static overrideModule(ngModule: Type, override: MetadataOverride): - typeof TestBedRender3 { + static overrideModule(ngModule: Type, override: MetadataOverride): TestBedStatic { _getTestBedRender3().overrideModule(ngModule, override); - return TestBedRender3; + return TestBedRender3 as any as TestBedStatic; } static overrideComponent(component: Type, override: MetadataOverride): - typeof TestBedRender3 { + TestBedStatic { _getTestBedRender3().overrideComponent(component, override); - return TestBedRender3; + return TestBedRender3 as any as TestBedStatic; } static overrideDirective(directive: Type, override: MetadataOverride): - typeof TestBedRender3 { + TestBedStatic { _getTestBedRender3().overrideDirective(directive, override); - return TestBedRender3; + return TestBedRender3 as any as TestBedStatic; } - static overridePipe(pipe: Type, override: MetadataOverride): typeof TestBedRender3 { + static overridePipe(pipe: Type, override: MetadataOverride): TestBedStatic { _getTestBedRender3().overridePipe(pipe, override); - return TestBedRender3; + return TestBedRender3 as any as TestBedStatic; } - static overrideTemplate(component: Type, template: string): typeof TestBedRender3 { + static overrideTemplate(component: Type, template: string): TestBedStatic { _getTestBedRender3().overrideComponent(component, {set: {template, templateUrl: null !}}); - return TestBedRender3; + return TestBedRender3 as any as TestBedStatic; } /** @@ -109,10 +108,9 @@ export class TestBedRender3 { * * Note: This works for JIT and AOTed components as well. */ - static overrideTemplateUsingTestingModule(component: Type, template: string): - typeof TestBedRender3 { + static overrideTemplateUsingTestingModule(component: Type, template: string): TestBedStatic { _getTestBedRender3().overrideTemplateUsingTestingModule(component, template); - return TestBedRender3; + return TestBedRender3 as any as TestBedStatic; } overrideTemplateUsingTestingModule(component: Type, template: string): void { @@ -122,15 +120,15 @@ export class TestBedRender3 { static overrideProvider(token: any, provider: { useFactory: Function, deps: any[], - }): typeof TestBedRender3; - static overrideProvider(token: any, provider: {useValue: any;}): typeof TestBedRender3; + }): TestBedStatic; + static overrideProvider(token: any, provider: {useValue: any;}): TestBedStatic; static overrideProvider(token: any, provider: { useFactory?: Function, useValue?: any, deps?: any[], - }): typeof TestBedRender3 { + }): TestBedStatic { _getTestBedRender3().overrideProvider(token, provider); - return TestBedRender3; + return TestBedRender3 as any as TestBedStatic; } /** @@ -147,7 +145,7 @@ export class TestBedRender3 { useFactory?: Function, useValue?: any, deps?: any[], - }): typeof TestBedRender3 { + }): TestBedStatic { throw new Error('Render3TestBed.deprecatedOverrideProvider is not implemented'); } @@ -159,9 +157,9 @@ export class TestBedRender3 { return _getTestBedRender3().createComponent(component); } - static resetTestingModule(): typeof TestBedRender3 { + static resetTestingModule(): TestBedStatic { _getTestBedRender3().resetTestingModule(); - return TestBedRender3; + return TestBedRender3 as any as TestBedStatic; } // Properties diff --git a/packages/core/testing/src/test_bed.ts b/packages/core/testing/src/test_bed.ts index 0043dfef91..71fb3605cc 100644 --- a/packages/core/testing/src/test_bed.ts +++ b/packages/core/testing/src/test_bed.ts @@ -12,7 +12,7 @@ import {AsyncTestCompleter} from './async_test_completer'; import {ComponentFixture} from './component_fixture'; import {MetadataOverride} from './metadata_override'; import {TestBedRender3, _getTestBedRender3} from './r3_test_bed'; -import {ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, TestComponentRenderer, TestModuleMetadata} from './test_bed_common'; +import {ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, TestBedStatic, TestComponentRenderer, TestModuleMetadata} from './test_bed_common'; import {TestingCompiler, TestingCompilerFactory} from './test_compiler'; const UNDEFINED = new Object(); @@ -20,6 +20,84 @@ const UNDEFINED = new Object(); let _nextRootElementId = 0; +export interface TestBed { + platform: PlatformRef; + + ngModule: Type|Type[]; + + /** + * 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//testing'. + * + * @experimental + */ + initTestEnvironment( + ngModule: Type|Type[], platform: PlatformRef, aotSummaries?: () => any[]): void; + + /** + * Reset the providers for the test injector. + * + * @experimental + */ + resetTestEnvironment(): void; + + resetTestingModule(): void; + + configureCompiler(config: {providers?: any[], useJit?: boolean}): void; + + configureTestingModule(moduleDef: TestModuleMetadata): void; + + compileComponents(): Promise; + + get(token: any, notFoundValue?: any): any; + + execute(tokens: any[], fn: Function, context?: any): any; + + overrideModule(ngModule: Type, override: MetadataOverride): void; + + overrideComponent(component: Type, override: MetadataOverride): void; + + overrideDirective(directive: Type, override: MetadataOverride): void; + + overridePipe(pipe: Type, override: MetadataOverride): void; + + /** + * Overwrites all providers for the given token with the given provider definition. + */ + overrideProvider(token: any, provider: { + useFactory: Function, + deps: any[], + }): void; + overrideProvider(token: any, provider: {useValue: any;}): void; + overrideProvider(token: any, provider: {useFactory?: Function, useValue?: any, deps?: any[]}): + void; + + /** + * Overwrites all providers for the given token with the given provider definition. + * + * @deprecated as it makes all NgModules lazy. Introduced only for migrating off of it. + */ + deprecatedOverrideProvider(token: any, provider: { + useFactory: Function, + deps: any[], + }): void; + deprecatedOverrideProvider(token: any, provider: {useValue: any;}): void; + deprecatedOverrideProvider( + token: any, provider: {useFactory?: Function, useValue?: any, deps?: any[]}): void; + + + overrideTemplateUsingTestingModule(component: Type, template: string): void; + + createComponent(component: Type): ComponentFixture; +} + /** * @description * Configures and initializes environment for unit testing and provides methods for @@ -30,7 +108,7 @@ let _nextRootElementId = 0; * Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3` * according to the compiler used. */ -export class TestBedViewEngine implements Injector { +export class TestBedViewEngine implements Injector, 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. @@ -59,27 +137,27 @@ export class TestBedViewEngine implements Injector { */ static resetTestEnvironment(): void { _getTestBedViewEngine().resetTestEnvironment(); } - static resetTestingModule(): typeof TestBed { + static resetTestingModule(): TestBedStatic { _getTestBedViewEngine().resetTestingModule(); - return TestBed; + return TestBedViewEngine as any as TestBedStatic; } /** * Allows overriding default compiler providers and settings * which are defined in test_injector.js */ - static configureCompiler(config: {providers?: any[]; useJit?: boolean;}): typeof TestBed { + static configureCompiler(config: {providers?: any[]; useJit?: boolean;}): TestBedStatic { _getTestBedViewEngine().configureCompiler(config); - return TestBed; + return TestBedViewEngine as any as TestBedStatic; } /** * Allows overriding default providers, directives, pipes, modules of the test injector, * which are defined in test_injector.js */ - static configureTestingModule(moduleDef: TestModuleMetadata): typeof TestBed { + static configureTestingModule(moduleDef: TestModuleMetadata): TestBedStatic { _getTestBedViewEngine().configureTestingModule(moduleDef); - return TestBed; + return TestBedViewEngine as any as TestBedStatic; } /** @@ -89,31 +167,31 @@ export class TestBedViewEngine implements Injector { */ static compileComponents(): Promise { return getTestBed().compileComponents(); } - static overrideModule(ngModule: Type, override: MetadataOverride): typeof TestBed { + static overrideModule(ngModule: Type, override: MetadataOverride): TestBedStatic { _getTestBedViewEngine().overrideModule(ngModule, override); - return TestBed; + return TestBedViewEngine as any as TestBedStatic; } static overrideComponent(component: Type, override: MetadataOverride): - typeof TestBed { + TestBedStatic { _getTestBedViewEngine().overrideComponent(component, override); - return TestBed; + return TestBedViewEngine as any as TestBedStatic; } static overrideDirective(directive: Type, override: MetadataOverride): - typeof TestBed { + TestBedStatic { _getTestBedViewEngine().overrideDirective(directive, override); - return TestBed; + return TestBedViewEngine as any as TestBedStatic; } - static overridePipe(pipe: Type, override: MetadataOverride): typeof TestBed { + static overridePipe(pipe: Type, override: MetadataOverride): TestBedStatic { _getTestBedViewEngine().overridePipe(pipe, override); - return TestBed; + return TestBedViewEngine as any as TestBedStatic; } - static overrideTemplate(component: Type, template: string): typeof TestBed { + static overrideTemplate(component: Type, template: string): TestBedStatic { _getTestBedViewEngine().overrideComponent(component, {set: {template, templateUrl: null !}}); - return TestBed; + return TestBedViewEngine as any as TestBedStatic; } /** @@ -122,10 +200,9 @@ export class TestBedViewEngine implements Injector { * * Note: This works for JIT and AOTed components as well. */ - static overrideTemplateUsingTestingModule(component: Type, template: string): - typeof TestBed { + static overrideTemplateUsingTestingModule(component: Type, template: string): TestBedStatic { _getTestBedViewEngine().overrideTemplateUsingTestingModule(component, template); - return TestBed; + return TestBedViewEngine as any as TestBedStatic; } /** @@ -136,15 +213,15 @@ export class TestBedViewEngine implements Injector { static overrideProvider(token: any, provider: { useFactory: Function, deps: any[], - }): typeof TestBed; - static overrideProvider(token: any, provider: {useValue: any;}): typeof TestBed; + }): TestBedStatic; + static overrideProvider(token: any, provider: {useValue: any;}): TestBedStatic; static overrideProvider(token: any, provider: { useFactory?: Function, useValue?: any, deps?: any[], - }): typeof TestBed { + }): TestBedStatic { _getTestBedViewEngine().overrideProvider(token, provider as any); - return TestBed; + return TestBedViewEngine as any as TestBedStatic; } /** @@ -161,9 +238,9 @@ export class TestBedViewEngine implements Injector { useFactory?: Function, useValue?: any, deps?: any[], - }): typeof TestBed { + }): TestBedStatic { _getTestBedViewEngine().deprecatedOverrideProvider(token, provider as any); - return TestBed; + return TestBedViewEngine as any as TestBedStatic; } static get(token: any, notFoundValue: any = Injector.THROW_IF_NOT_FOUND) { @@ -559,7 +636,8 @@ export class TestBedViewEngine implements Injector { * Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3` * according to the compiler used. */ -export const TestBed = ivyEnabled ? TestBedRender3 : TestBedViewEngine; +export const TestBed: TestBedStatic = + ivyEnabled ? TestBedRender3 as any as TestBedStatic : TestBedViewEngine as any as TestBedStatic; /** * Returns a singleton of the applicable `TestBed`. @@ -568,8 +646,7 @@ export const TestBed = ivyEnabled ? TestBedRender3 : TestBedViewEngine; * * @experimental */ -export const getTestBed: () => TestBedRender3 | TestBedViewEngine = - ivyEnabled ? _getTestBedRender3 : _getTestBedViewEngine; +export const getTestBed: () => TestBed = ivyEnabled ? _getTestBedRender3 : _getTestBedViewEngine; let testBed: TestBedViewEngine; diff --git a/packages/core/testing/src/test_bed_common.ts b/packages/core/testing/src/test_bed_common.ts index b590305987..7f029a7256 100644 --- a/packages/core/testing/src/test_bed_common.ts +++ b/packages/core/testing/src/test_bed_common.ts @@ -6,7 +6,11 @@ * found in the LICENSE file at https://angular.io/license */ -import {InjectionToken, SchemaMetadata} from '@angular/core'; +import {Component, Directive, InjectionToken, NgModule, Pipe, PlatformRef, SchemaMetadata, Type} from '@angular/core'; + +import {ComponentFixture} from './component_fixture'; +import {MetadataOverride} from './metadata_override'; +import {TestBed} from './test_bed'; /** * An abstract class for inserting the root test component element in a platform independent way. @@ -38,3 +42,95 @@ export type TestModuleMetadata = { schemas?: Array, aotSummaries?: () => any[], }; + +/** + * Static methods implemented by the `TestBedViewEngine` and `TestBedRender3` + */ +export interface TestBedStatic { + new (...args: any[]): TestBed; + + initTestEnvironment( + ngModule: Type|Type[], platform: PlatformRef, aotSummaries?: () => any[]): TestBed; + + /** + * Reset the providers for the test injector. + * + * @experimental + */ + resetTestEnvironment(): void; + + resetTestingModule(): TestBedStatic; + + /** + * Allows overriding default compiler providers and settings + * which are defined in test_injector.js + */ + configureCompiler(config: {providers?: any[]; useJit?: boolean;}): TestBedStatic; + + /** + * Allows overriding default providers, directives, pipes, modules of the test injector, + * which are defined in test_injector.js + */ + configureTestingModule(moduleDef: TestModuleMetadata): TestBedStatic; + + /** + * Compile components with a `templateUrl` for the test's NgModule. + * It is necessary to call this function + * as fetching urls is asynchronous. + */ + compileComponents(): Promise; + + overrideModule(ngModule: Type, override: MetadataOverride): TestBedStatic; + + overrideComponent(component: Type, override: MetadataOverride): TestBedStatic; + + overrideDirective(directive: Type, override: MetadataOverride): TestBedStatic; + + overridePipe(pipe: Type, override: MetadataOverride): TestBedStatic; + + overrideTemplate(component: Type, template: string): TestBedStatic; + + /** + * Overrides the template of the given component, compiling the template + * in the context of the TestingModule. + * + * Note: This works for JIT and AOTed components as well. + */ + overrideTemplateUsingTestingModule(component: Type, template: string): TestBedStatic; + + /** + * Overwrites all providers for the given token with the given provider definition. + * + * Note: This works for JIT and AOTed components as well. + */ + overrideProvider(token: any, provider: { + useFactory: Function, + deps: any[], + }): TestBedStatic; + overrideProvider(token: any, provider: {useValue: any;}): TestBedStatic; + overrideProvider(token: any, provider: { + useFactory?: Function, + useValue?: any, + deps?: any[], + }): TestBedStatic; + + /** + * Overwrites all providers for the given token with the given provider definition. + * + * @deprecated as it makes all NgModules lazy. Introduced only for migrating off of it. + */ + deprecatedOverrideProvider(token: any, provider: { + useFactory: Function, + deps: any[], + }): void; + deprecatedOverrideProvider(token: any, provider: {useValue: any;}): void; + deprecatedOverrideProvider(token: any, provider: { + useFactory?: Function, + useValue?: any, + deps?: any[], + }): TestBedStatic; + + get(token: any, notFoundValue?: any): any; + + createComponent(component: Type): ComponentFixture; +} diff --git a/packages/core/testing/src/testing.ts b/packages/core/testing/src/testing.ts index e16711c006..baefc11881 100644 --- a/packages/core/testing/src/testing.ts +++ b/packages/core/testing/src/testing.ts @@ -15,10 +15,9 @@ export * from './async'; export * from './component_fixture'; export * from './fake_async'; -export * from './test_bed'; +export {TestBed, getTestBed, inject, InjectSetupWrapper, withModule} from './test_bed'; export * from './test_bed_common'; -export * from './r3_test_bed'; export * from './before_each'; export * from './metadata_override'; -export * from './metadata_overrider'; +export {MetadataOverrider as ɵMetadataOverrider} from './metadata_overrider'; export * from './private_export_testing'; diff --git a/packages/platform-browser-dynamic/testing/src/metadata_overrider.ts b/packages/platform-browser-dynamic/testing/src/metadata_overrider.ts index bc2c957942..56b9056608 100644 --- a/packages/platform-browser-dynamic/testing/src/metadata_overrider.ts +++ b/packages/platform-browser-dynamic/testing/src/metadata_overrider.ts @@ -6,5 +6,5 @@ * found in the LICENSE file at https://angular.io/license */ -// `MetadataOverrider` has been moved to core to allow using it from the render3 TestBed -export {MetadataOverrider} from '@angular/core/testing'; +// `MetadataOverrider` has been moved to core/testing to allow using it from the render3 TestBed +export {ɵMetadataOverrider as MetadataOverrider} from '@angular/core/testing'; diff --git a/tools/public_api_guard/core/testing.d.ts b/tools/public_api_guard/core/testing.d.ts index afd0340bb6..f4b77d98fd 100644 --- a/tools/public_api_guard/core/testing.d.ts +++ b/tools/public_api_guard/core/testing.d.ts @@ -1,5 +1,3 @@ -export declare function _getTestBedRender3(): TestBedRender3; - export declare function async(fn: Function): (done: any) => any; export declare class ComponentFixture { @@ -39,7 +37,7 @@ export declare function flush(maxTurns?: number): number; export declare function flushMicrotasks(): void; /** @experimental */ -export declare const getTestBed: () => TestBedRender3 | TestBedViewEngine; +export declare const getTestBed: () => TestBed; export declare function inject(tokens: any[], fn: Function): () => any; @@ -56,27 +54,25 @@ export declare type MetadataOverride = { set?: Partial; }; -export declare class MetadataOverrider { - overrideMetadata(metadataClass: { - new (options: T): C; - }, oldMetadata: C, override: MetadataOverride): C; -} - /** @experimental */ export declare function resetFakeAsyncZone(): void; -export declare const TestBed: typeof TestBedRender3 | typeof TestBedViewEngine; +export declare const TestBed: TestBedStatic; -export declare class TestBedRender3 { - ngModule: Type | Type[]; - platform: PlatformRef; +export interface TestBedStatic { + new (...args: any[]): TestBed; compileComponents(): Promise; configureCompiler(config: { providers?: any[]; useJit?: boolean; - }): void; - configureTestingModule(moduleDef: TestModuleMetadata): void; - createComponent(type: Type): ComponentFixture; + }): TestBedStatic; + configureTestingModule(moduleDef: TestModuleMetadata): TestBedStatic; + createComponent(component: Type): ComponentFixture; + deprecatedOverrideProvider(token: any, provider: { + useFactory?: Function; + useValue?: any; + deps?: any[]; + }): TestBedStatic; deprecatedOverrideProvider(token: any, provider: { useValue: any; }): void; @@ -84,119 +80,28 @@ export declare class TestBedRender3 { useFactory: Function; deps: any[]; }): void; - execute(tokens: any[], fn: Function, context?: any): any; get(token: any, notFoundValue?: any): any; - /** @experimental */ initTestEnvironment(ngModule: Type | Type[], platform: PlatformRef, aotSummaries?: () => any[]): void; - overrideComponent(component: Type, override: MetadataOverride): void; - overrideDirective(directive: Type, override: MetadataOverride): void; - overrideModule(ngModule: Type, override: MetadataOverride): void; - overridePipe(pipe: Type, override: MetadataOverride): void; + initTestEnvironment(ngModule: Type | Type[], platform: PlatformRef, aotSummaries?: () => any[]): TestBed; + overrideComponent(component: Type, override: MetadataOverride): TestBedStatic; + overrideDirective(directive: Type, override: MetadataOverride): TestBedStatic; + overrideModule(ngModule: Type, override: MetadataOverride): TestBedStatic; + overridePipe(pipe: Type, override: MetadataOverride): TestBedStatic; + overrideProvider(token: any, provider: { + useValue: any; + }): TestBedStatic; overrideProvider(token: any, provider: { useFactory?: Function; useValue?: any; deps?: any[]; - }): void; - overrideTemplateUsingTestingModule(component: Type, template: string): void; - /** @experimental */ resetTestEnvironment(): void; - resetTestingModule(): void; - static compileComponents(): Promise; - static configureCompiler(config: { - providers?: any[]; - useJit?: boolean; - }): typeof TestBedRender3; - static configureTestingModule(moduleDef: TestModuleMetadata): typeof TestBedRender3; - static createComponent(component: Type): ComponentFixture; - static deprecatedOverrideProvider(token: any, provider: { - useValue: any; - }): void; - /** @deprecated */ static deprecatedOverrideProvider(token: any, provider: { - useFactory: Function; - deps: any[]; - }): void; - static get(token: any, notFoundValue?: any): any; - /** @experimental */ static initTestEnvironment(ngModule: Type | Type[], platform: PlatformRef, aotSummaries?: () => any[]): TestBedRender3; - static overrideComponent(component: Type, override: MetadataOverride): typeof TestBedRender3; - static overrideDirective(directive: Type, override: MetadataOverride): typeof TestBedRender3; - static overrideModule(ngModule: Type, override: MetadataOverride): typeof TestBedRender3; - static overridePipe(pipe: Type, override: MetadataOverride): typeof TestBedRender3; - static overrideProvider(token: any, provider: { - useFactory: Function; - deps: any[]; - }): typeof TestBedRender3; - static overrideProvider(token: any, provider: { - useValue: any; - }): typeof TestBedRender3; - static overrideTemplate(component: Type, template: string): typeof TestBedRender3; - static overrideTemplateUsingTestingModule(component: Type, template: string): typeof TestBedRender3; - /** @experimental */ static resetTestEnvironment(): void; - static resetTestingModule(): typeof TestBedRender3; -} - -export declare class TestBedViewEngine implements Injector { - ngModule: Type | Type[]; - platform: PlatformRef; - compileComponents(): Promise; - configureCompiler(config: { - providers?: any[]; - useJit?: boolean; - }): void; - configureTestingModule(moduleDef: TestModuleMetadata): void; - createComponent(component: Type): ComponentFixture; - /** @deprecated */ deprecatedOverrideProvider(token: any, provider: { - useFactory: Function; - deps: any[]; - }): void; - deprecatedOverrideProvider(token: any, provider: { - useValue: any; - }): void; - execute(tokens: any[], fn: Function, context?: any): any; - get(token: any, notFoundValue?: any): any; - /** @experimental */ initTestEnvironment(ngModule: Type | Type[], platform: PlatformRef, aotSummaries?: () => any[]): void; - overrideComponent(component: Type, override: MetadataOverride): void; - overrideDirective(directive: Type, override: MetadataOverride): void; - overrideModule(ngModule: Type, override: MetadataOverride): void; - overridePipe(pipe: Type, override: MetadataOverride): void; + }): TestBedStatic; overrideProvider(token: any, provider: { useFactory: Function; deps: any[]; - }): void; - overrideProvider(token: any, provider: { - useValue: any; - }): void; - overrideTemplateUsingTestingModule(component: Type, template: string): void; + }): TestBedStatic; + overrideTemplate(component: Type, template: string): TestBedStatic; + overrideTemplateUsingTestingModule(component: Type, template: string): TestBedStatic; /** @experimental */ resetTestEnvironment(): void; - resetTestingModule(): void; - static compileComponents(): Promise; - static configureCompiler(config: { - providers?: any[]; - useJit?: boolean; - }): typeof TestBed; - static configureTestingModule(moduleDef: TestModuleMetadata): typeof TestBed; - static createComponent(component: Type): ComponentFixture; - static deprecatedOverrideProvider(token: any, provider: { - useValue: any; - }): void; - /** @deprecated */ static deprecatedOverrideProvider(token: any, provider: { - useFactory: Function; - deps: any[]; - }): void; - static get(token: any, notFoundValue?: any): any; - /** @experimental */ static initTestEnvironment(ngModule: Type | Type[], platform: PlatformRef, aotSummaries?: () => any[]): TestBedViewEngine; - static overrideComponent(component: Type, override: MetadataOverride): typeof TestBed; - static overrideDirective(directive: Type, override: MetadataOverride): typeof TestBed; - static overrideModule(ngModule: Type, override: MetadataOverride): typeof TestBed; - static overridePipe(pipe: Type, override: MetadataOverride): typeof TestBed; - static overrideProvider(token: any, provider: { - useValue: any; - }): typeof TestBed; - static overrideProvider(token: any, provider: { - useFactory: Function; - deps: any[]; - }): typeof TestBed; - static overrideTemplate(component: Type, template: string): typeof TestBed; - static overrideTemplateUsingTestingModule(component: Type, template: string): typeof TestBed; - /** @experimental */ static resetTestEnvironment(): void; - static resetTestingModule(): typeof TestBed; + resetTestingModule(): TestBedStatic; } /** @experimental */