TestBed

Experimental Class

Class Overview

class TestBed {
  staticinitTestEnvironment(ngModule: Type<any>, platform: PlatformRef) : TestBed
  staticresetTestEnvironment()
  staticresetTestingModule() : typeof TestBed
  staticconfigureCompiler(config: {providers?: any[]; useJit?: boolean;}) : typeof TestBed
  staticconfigureTestingModule(moduleDef: TestModuleMetadata) : typeof TestBed
  staticcompileComponents() : Promise<any>
  staticoverrideModule(ngModule: Type<any>, override: MetadataOverride<NgModule>) : typeof TestBed
  staticoverrideComponent(component: Type<any>, override: MetadataOverride<Component>) : typeof TestBed
  staticoverrideDirective(directive: Type<any>, override: MetadataOverride<Directive>) : typeof TestBed
  staticoverridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>) : typeof TestBed
  staticget(token: any, notFoundValue?: any)
  staticcreateComponent(component: Type<T>) : ComponentFixture<T>
  initTestEnvironment(ngModule: Type<any>, platform: PlatformRef)
  resetTestEnvironment()
  resetTestingModule()
  platform : PlatformRef
  ngModule : Type<any>
  configureCompiler(config: {providers?: any[], useJit?: boolean})
  configureTestingModule(moduleDef: TestModuleMetadata)
  compileComponents() : Promise<any>
  get(token: any, notFoundValue?: any)
  execute(tokens: any[], fn: Function) : any
  overrideModule(ngModule: Type<any>, override: MetadataOverride<NgModule>) : void
  overrideComponent(component: Type<any>, override: MetadataOverride<Component>) : void
  overrideDirective(directive: Type<any>, override: MetadataOverride<Directive>) : void
  overridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>) : void
  createComponent(component: Type<T>) : ComponentFixture<T>
}

Class Description

Static Members

initTestEnvironment(ngModule: Type<any>, platform: PlatformRef) : TestBed

Initialize 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//testing'.

resetTestEnvironment()

Reset the providers for the test injector.

resetTestingModule() : typeof TestBed
configureCompiler(config: {providers?: any[]; useJit?: boolean;}) : typeof TestBed

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

configureTestingModule(moduleDef: TestModuleMetadata) : typeof TestBed

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

compileComponents() : Promise<any>

Compile components with a templateUrl for the test's NgModule. It is necessary to call this function as fetching urls is asynchronous.

overrideModule(ngModule: Type<any>, override: MetadataOverride<NgModule>) : typeof TestBed
overrideComponent(component: Type<any>, override: MetadataOverride<Component>) : typeof TestBed
overrideDirective(directive: Type<any>, override: MetadataOverride<Directive>) : typeof TestBed
overridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>) : typeof TestBed
get(token: any, notFoundValue?: any)
createComponent(component: Type<T>) : ComponentFixture<T>

Class Details

initTestEnvironment(ngModule: Type<any>, platform: PlatformRef)

Initialize 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//testing'.

resetTestEnvironment()

Reset the providers for the test injector.

resetTestingModule()
platform : PlatformRef
ngModule : Type<any>
configureCompiler(config: {providers?: any[], useJit?: boolean})
configureTestingModule(moduleDef: TestModuleMetadata)
compileComponents() : Promise<any>
get(token: any, notFoundValue?: any)
execute(tokens: any[], fn: Function) : any
overrideModule(ngModule: Type<any>, override: MetadataOverride<NgModule>) : void
overrideComponent(component: Type<any>, override: MetadataOverride<Component>) : void
overrideDirective(directive: Type<any>, override: MetadataOverride<Directive>) : void
overridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>) : void
createComponent(component: Type<T>) : ComponentFixture<T>

exported from @angular/core/testing/index, defined in @angular/core/testing/test_bed.ts

doc_Angular
2016-10-06 09:47:06
Comments
Leave a Comment

Please login to continue.