TestBedViewEngine
和 TestBedRender3
实现的静态方法
Static methods implemented by the TestBedViewEngine
and TestBedRender3
interface TestBedStatic {
new (...args: any[]): TestBed
initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): 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>
}
方法
|
---|
重置测试注入器的提供者。 Reset the providers for the test injector. |
resetTestEnvironment(): void
参数没有参数。 返回值void
|
|
---|
允许覆盖在 test_injector.js 中定义的默认编译器提供者和设置 Allows overriding default compiler providers and settings which are defined in test_injector.js |
|
|
---|
允许覆盖测试注入器的默认提供者、指令、管道、模块,它们在 test_injector.js 中定义 Allows overriding default providers, directives, pipes, modules of the test injector, which are defined in test_injector.js |
|
|
---|
使用测试用的 NgModule templateUrl 编译组件。由于提取网址是异步的,因此必须调用此函数。 Compile components with a templateUrl for the test's NgModule. It is necessary to call this function as fetching urls is asynchronous. |
compileComponents(): Promise<any>
参数没有参数。 返回值Promise<any>
|
overrideTemplateUsingTestingModule() |
---|
覆盖给定组件的模板,在 TestingModule 的上下文中编译该模板。 Overrides the template of the given component, compiling the template in the context of the TestingModule. |
|
注意:这也适用于 JIT 和 AOT 的组件。 Note: This works for JIT and AOTed components as well. |
|
---|
使用给定的提供者定义覆盖给定令牌的所有提供者。 Overwrites all providers for the given token with the given provider definition. |
overrideProvider(token: any, provider: { useValue: any; }): TestBedStatic
参数 token | any | | provider | { useValue: any; } | |
返回值TestBedStatic
|
overrideProvider(token: any, provider: { useFactory?: Function; useValue?: any; deps?: any[]; }): TestBedStatic
参数 token | any | | provider | object | |
返回值TestBedStatic
|
注意:这也适用于 JIT 和 AOT 的组件。 Note: This works for JIT and AOTed components as well. |
|
---|
get(token: any, notFoundValue?: any): any
从 v9.0.0 开始使用 TestBed.inject Deprecated from v9.0.0 use TestBed.inject 参数 token | any | | notFoundValue | any | 可选. 默认值是 `undefined`. |
返回值any
|