Static methods implemented by the TestBed.
API
interface TestBedStatic extends TestBed {
override readonly platform: PlatformRef;
override readonly ngModule: Type<any> | Type<any>[];
override initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, options?: TestEnvironmentOptions | undefined): void;
override resetTestEnvironment(): void;
override resetTestingModule(): TestBed;
override configureCompiler(config: { providers?: any[] | undefined; useJit?: boolean | undefined; }): void;
override configureTestingModule(moduleDef: TestModuleMetadata): TestBed;
override compileComponents(): Promise<any>;
override inject<T>(token: ProviderToken<T>, notFoundValue: undefined, options: InjectOptions & { optional?: false | undefined; }): T;
override inject<T>(token: ProviderToken<T>, notFoundValue: null | undefined, options: InjectOptions): T | null;
override inject<T>(token: ProviderToken<T>, notFoundValue?: T | undefined, options?: InjectOptions | undefined): T;
override runInInjectionContext<T>(fn: () => T): T;
override execute(tokens: any[], fn: Function, context?: any): any;
override overrideModule(ngModule: Type<any>, override: MetadataOverride<NgModule>): TestBed;
override overrideComponent(component: Type<any>, override: MetadataOverride<Component>): TestBed;
override overrideDirective(directive: Type<any>, override: MetadataOverride<Directive>): TestBed;
override overridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>): TestBed;
override overrideTemplate(component: Type<any>, template: string): TestBed;
override overrideProvider(token: any, provider: { useFactory: Function; deps: any[]; multi?: boolean | undefined; }): TestBed;
override overrideProvider(token: any, provider: { useValue: any; multi?: boolean | undefined; }): TestBed;
override overrideProvider(token: any, provider: { useFactory?: Function | undefined; useValue?: any; deps?: any[] | undefined; multi?: boolean | undefined; }): TestBed;
override overrideTemplateUsingTestingModule(component: Type<any>, template: string): TestBed;
override createComponent<T>(component: Type<T>, options?: TestComponentOptions | undefined): ComponentFixture<T>;
override flushEffects(): void;
override tick(): void;
}
platform
PlatformRefngModule
Type<any> | Type<any>[]initTestEnvironment
voidInitialize 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/
Type<any> | Type<any>[]
PlatformRef
void
resetTestEnvironment
voidReset the providers for the test injector.
void
configureCompiler
void{ providers?: any[] | undefined; useJit?: boolean | undefined; }
void
compileComponents
Promise<any>Promise<any>
inject
TProviderToken<T>
undefined
InjectOptions & { optional?: false | undefined; }
T
inject
T | nullProviderToken<T>
null | undefined
InjectOptions
T | null
inject
TProviderToken<T>
T | undefined
InjectOptions | undefined
T
runInInjectionContext
Texecute
anyany[]
Function
any
any
overrideModule
TestBedoverrideComponent
TestBedoverrideDirective
TestBedoverridePipe
TestBedoverrideProvider
TestBedOverwrites all providers for the given token with the given provider definition.
any
{ useFactory: Function; deps: any[]; multi?: boolean | undefined; }
TestBed
overrideProvider
TestBedoverrideProvider
TestBedany
{ useFactory?: Function | undefined; useValue?: any; deps?: any[] | undefined; multi?: boolean | undefined; }
TestBed
overrideTemplateUsingTestingModule
TestBedcreateComponent
ComponentFixture<T>flushEffects
voidExecute any pending effects.
void
tick
voidExecute any pending work required to synchronize model to the UI.
void