The Testability service provides testing hooks that can be accessed from the browser.
API
class Testability implements PublicTestability {
constructor(_ngZone: NgZone, registry: TestabilityRegistry, testabilityGetter: GetTestability): Testability;
isStable(): boolean;
whenStable(doneCb: Function, timeout?: number | undefined, updateCb?: Function | undefined): void;
findProviders(using: any, provider: string, exactMatch: boolean): any[];
}
constructor
TestabilityTestability
isStable
booleanWhether an associated application is stable
boolean
whenStable
voidWait for the application to be stable with a timeout. If the timeout is reached before that happens, the callback receives a list of the macro tasks that were pending, otherwise null.
FunctionThe callback to invoke when Angular is stable or the timeout expires whichever comes first.
number | undefinedOptional. The maximum time to wait for Angular to become stable. If not specified, whenStable() will wait forever.
Function | undefinedOptional. If specified, this callback will be invoked whenever the set of pending macrotasks changes. If this callback returns true doneCb will not be invoked and no further updates will be issued.
void
findProviders
any[]Find providers by name
anyThe root element to search from
stringThe name of binding variable
booleanWhether using exactMatch
any[]
Description
The Testability service provides testing hooks that can be accessed from the browser.
Angular applications bootstrapped using an NgModule (via @NgModule.bootstrap field) will also instantiate Testability by default (in both development and production modes).
For applications bootstrapped using the bootstrapApplication function, Testability is not included by default. You can include it into your applications by getting the list of necessary providers using the provideProtractorTestingSupport() function and adding them into the options.providers array. Example:
import {provideProtractorTestingSupport} from '@angular/platform-browser';
await bootstrapApplication(RootComponent, providers: [provideProtractorTestingSupport()]);