TestBedStatic
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>[]PlatformRefvoidresetTestEnvironment
voidReset the providers for the test injector.
voidconfigureCompiler
void{ providers?: any[] | undefined; useJit?: boolean | undefined; }voidcompileComponents
Promise<any>Promise<any>inject
TProviderToken<T>undefinedInjectOptions & { optional?: false | undefined; }Tinject
T | nullProviderToken<T>null | undefinedInjectOptionsT | nullinject
TProviderToken<T>T | undefinedInjectOptions | undefinedTrunInInjectionContext
Texecute
anyany[]FunctionanyanyoverrideModule
TestBedoverrideComponent
TestBedoverrideDirective
TestBedoverridePipe
TestBedoverrideProvider
TestBedOverwrites all providers for the given token with the given provider definition.
any{ useFactory: Function; deps: any[]; multi?: boolean | undefined; }TestBedoverrideProvider
TestBedoverrideProvider
TestBedany{ useFactory?: Function | undefined; useValue?: any; deps?: any[] | undefined; multi?: boolean | undefined; }TestBedoverrideTemplateUsingTestingModule
TestBedcreateComponent
ComponentFixture<T>flushEffects
voidExecute any pending effects.
voidtick
voidExecute any pending work required to synchronize model to the UI.
void