填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

TestBedStatic

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: Type<T> | InjectionToken<T> | AbstractType<T>, notFoundValue?: T, flags?: InjectFlags): T get<T>(token: Type<T> | InjectionToken<T>, notFoundValue?: T, flags?: InjectFlags): any createComponent<T>(component: Type<T>): ComponentFixture<T> }
      
      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: Type<T> | InjectionToken<T> | AbstractType<T>, notFoundValue?: T, flags?: InjectFlags): T
  get<T>(token: Type<T> | InjectionToken<T>, notFoundValue?: T, flags?: InjectFlags): any
  createComponent<T>(component: Type<T>): ComponentFixture<T>
}
    

方法

new (...args: any[]): TestBed
      
      new (...args: any[]): TestBed
    
参数
args any[]
返回值

TestBed

initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): TestBed
      
      initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): TestBed
    
参数
ngModule Type | Type[]
platform PlatformRef
aotSummaries () => any[]

可选. 默认值是 undefined.

返回值

TestBed

Reset the providers for the test injector.

resetTestEnvironment(): void
      
      resetTestEnvironment(): void
    
参数

没有参数。

返回值

void

resetTestingModule(): TestBedStatic
      
      resetTestingModule(): TestBedStatic
    
参数

没有参数。

返回值

TestBedStatic

Allows overriding default compiler providers and settings which are defined in test_injector.js

configureCompiler(config: { providers?: any[]; useJit?: boolean; }): TestBedStatic
      
      configureCompiler(config: { providers?: any[]; useJit?: boolean; }): TestBedStatic
    
参数
config object
返回值

TestBedStatic

Allows overriding default providers, directives, pipes, modules of the test injector, which are defined in test_injector.js

configureTestingModule(moduleDef: TestModuleMetadata): TestBedStatic
      
      configureTestingModule(moduleDef: TestModuleMetadata): TestBedStatic
    
参数
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<any>
      
      compileComponents(): Promise<any>
    
参数

没有参数。

返回值

Promise<any>

overrideModule(ngModule: Type<any>, override: MetadataOverride<NgModule>): TestBedStatic
      
      overrideModule(ngModule: Type<any>, override: MetadataOverride<NgModule>): TestBedStatic
    
参数
ngModule Type
override MetadataOverride
返回值

TestBedStatic

overrideComponent(component: Type<any>, override: MetadataOverride<Component>): TestBedStatic
      
      overrideComponent(component: Type<any>, override: MetadataOverride<Component>): TestBedStatic
    
参数
component Type
override MetadataOverride
返回值

TestBedStatic

overrideDirective(directive: Type<any>, override: MetadataOverride<Directive>): TestBedStatic
      
      overrideDirective(directive: Type<any>, override: MetadataOverride<Directive>): TestBedStatic
    
参数
directive Type
override MetadataOverride
返回值

TestBedStatic

overridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>): TestBedStatic
      
      overridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>): TestBedStatic
    
参数
pipe Type
override MetadataOverride
返回值

TestBedStatic

overrideTemplate(component: Type<any>, template: string): TestBedStatic
      
      overrideTemplate(component: Type<any>, template: string): TestBedStatic
    
参数
component Type
template string
返回值

TestBedStatic

Overrides the template of the given component, compiling the template in the context of the TestingModule.

overrideTemplateUsingTestingModule(component: Type<any>, template: string): TestBedStatic
      
      overrideTemplateUsingTestingModule(component: Type<any>, template: string): TestBedStatic
    
参数
component Type
template string
返回值

TestBedStatic

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
      
      overrideProvider(token: any, provider: { useValue: any; }): TestBedStatic
    
参数
token any
provider { useValue: any; }
返回值

TestBedStatic

overrideProvider(token: any, provider: { useFactory?: Function; useValue?: any; deps?: any[]; }): TestBedStatic
      
      overrideProvider(token: any, provider: { useFactory?: Function; useValue?: any; deps?: any[]; }): TestBedStatic
    
参数
token any
provider object
返回值

TestBedStatic

Note: This works for JIT and AOTed components as well.

inject<T>(token: Type<T> | InjectionToken<T> | AbstractType<T>, notFoundValue: null, flags?: InjectFlags): T | null
      
      inject<T>(token: Type<T> | InjectionToken<T> | AbstractType<T>, notFoundValue: null, flags?: InjectFlags): T | null
    
参数
token Type | InjectionToken | AbstractType
notFoundValue null
flags InjectFlags

可选. 默认值是 undefined.

返回值

T | null

get(token: any, notFoundValue?: any): any
      
      get(token: any, notFoundValue?: any): any
    

Deprecated from v9.0.0 use TestBed.inject

参数
token any
notFoundValue any

可选. 默认值是 undefined.

返回值

any

createComponent<T>(component: Type<T>): ComponentFixture<T>
      
      createComponent<T>(component: Type<T>): ComponentFixture<T>
    
参数
component Type
返回值

ComponentFixture<T>