interface
Static methods implemented by the TestBedViewEngine
and TestBedRender3
interface TestBedStatic { new (...args: any[]): TestBed initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, options?: { teardown?: ModuleTeardownOptions; }): TestBed resetTestEnvironment(): void resetTestingModule(): TestBedStatic configureCompiler(config: { providers?: any[]; useJit?: boolean; }): TestBedStatic configureTestingModule(moduleDef: TestModuleMetadata): TestBedStatic compileComponents(): Promise<any> overrideModule(ngModule: Type<any>, override: MetadataOverride<NgModule>): TestBedStatic overrideComponent(component: Type<any>, override: MetadataOverride<Component>): TestBedStatic overrideDirective(directive: Type<any>, override: MetadataOverride<Directive>): TestBedStatic overridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>): TestBedStatic overrideTemplate(component: Type<any>, template: string): TestBedStatic overrideTemplateUsingTestingModule(component: Type<any>, template: string): TestBedStatic overrideProvider(token: any, provider: { useFactory: Function; deps: any[]; }): TestBedStatic inject<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): any createComponent<T>(component: Type<T>): ComponentFixture<T> }
construct signature |
---|
initTestEnvironment() | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
ngModule | Type | |
platform | PlatformRef | |
options | object | Optional. Default is |
initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): TestBed
ngModule | Type | |
platform | PlatformRef | |
aotSummaries | () => any[] | Optional. Default is |
resetTestEnvironment() |
---|
Reset the providers for the test injector. |
|
resetTestingModule() |
---|
configureCompiler() | |||
---|---|---|---|
Allows overriding default compiler providers and settings which are defined in test_injector.js | |||
|
config | object |
configureTestingModule() | |||
---|---|---|---|
Allows overriding default providers, directives, pipes, modules of the test injector, which are defined in test_injector.js | |||
|
moduleDef | TestModuleMetadata |
compileComponents() |
---|
Compile components with a |
|
overrideModule() | ||||||
---|---|---|---|---|---|---|
|
ngModule | Type | |
override | MetadataOverride |
overrideComponent() | ||||||
---|---|---|---|---|---|---|
|
component | Type | |
override | MetadataOverride |
overrideDirective() | ||||||
---|---|---|---|---|---|---|
|
directive | Type | |
override | MetadataOverride |
overridePipe() | ||||||
---|---|---|---|---|---|---|
|
pipe | Type | |
override | MetadataOverride |
overrideTemplate() | ||||||
---|---|---|---|---|---|---|
|
component | Type | |
template | string |
overrideTemplateUsingTestingModule() | ||||||
---|---|---|---|---|---|---|
Overrides the template of the given component, compiling the template in the context of the TestingModule. | ||||||
|
component | Type | |
template | string |
Note: This works for JIT and AOTed components as well.
overrideProvider() | ||||||
---|---|---|---|---|---|---|
Overwrites all providers for the given token with the given provider definition. | ||||||
|
token | any | |
provider | object |
overrideProvider(token: any, provider: { useValue: any; }): TestBedStatic
token | any | |
provider | { useValue: any; } |
overrideProvider(token: any, provider: { useFactory?: Function; useValue?: any; deps?: any[]; }): TestBedStatic
token | any | |
provider | object |
Note: This works for JIT and AOTed components as well.
inject() | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
token | ProviderToken | |
notFoundValue | T | Optional. Default is |
flags | InjectFlags | Optional. Default is |
T
inject<T>(token: ProviderToken<T>, notFoundValue: null, flags?: InjectFlags): T | null
token | ProviderToken | |
notFoundValue | null | |
flags | InjectFlags | Optional. Default is |
T | null
get() | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
token | ProviderToken | |
notFoundValue | T | Optional. Default is |
flags | InjectFlags | Optional. Default is |
any
get(token: any, notFoundValue?: any): any
Deprecated from v9.0.0 use TestBed.inject
token | any | |
notFoundValue | any | Optional. Default is |
any
createComponent() |
---|
© 2010–2021 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v12.angular.io/api/core/testing/TestBedStatic