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

Testability

Testability 服务提供了可以从浏览器和诸如 Protractor 之类的服务访问的测试钩子。页面上每个自举的 Angular 应用程序都会有一个 Testability 实例。

The Testability service provides testing hooks that can be accessed from the browser. Each bootstrapped Angular application on the page will have an instance of Testability.

      
      class Testability implements PublicTestability {
  increasePendingRequestCount(): number
  decreasePendingRequestCount(): number
  isStable(): boolean
  whenStable(doneCb: Function, timeout?: number, updateCb?: Function): void
  getPendingRequestCount(): number
  findProviders(using: any, provider: string, exactMatch: boolean): any[]
}
    

Provided in

方法

增加待处理请求的数量

Increases the number of pending request

      
      increasePendingRequestCount(): number
    

现在可以使用 Zone 来跟踪未决请求。

Deprecated pending requests are now tracked with zones.

参数

没有参数。

返回值

number

减少待处理的请求数

Decreases the number of pending request

      
      decreasePendingRequestCount(): number
    

现在使用 Zone 跟踪待处理的请求

Deprecated pending requests are now tracked with zones

参数

没有参数。

返回值

number

关联的应用程序是否稳定

Whether an associated application is stable

      
      isStable(): boolean
    
参数

没有参数。

返回值

boolean

等待应用程序稳定并超时。如果在此之前已达到超时,则回调将收到未决的宏任务的列表,否则为 null。

Wait 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.

      
      whenStable(doneCb: Function, timeout?: number, updateCb?: Function): void
    
参数
doneCb Function

当 Angular 稳定或超时到期时调用的回调,以先到者为准。

The callback to invoke when Angular is stable or the timeout expires whichever comes first.

timeout number

可选的。等待 Angular 稳定下来的最长时间。如果未指定,那么 whenStable() 将永远等待。

Optional. The maximum time to wait for Angular to become stable. If not specified, whenStable() will wait forever.

可选. 默认值是 `undefined`.
updateCb Function

可选的。如果指定,则每当挂起的宏任务集发生更改时,都会调用此回调。如果此回调返回 true,那么将不会调用 doneCb,并且不会发出进一步的更新。

Optional. 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.

可选. 默认值是 `undefined`.
返回值

void

获取待处理的请求数

Get the number of pending requests

      
      getPendingRequestCount(): number
    

现在使用 Zone 跟踪待处理的请求

Deprecated pending requests are now tracked with zones

参数

没有参数。

返回值

number

按名称查找提供者

Find providers by name

      
      findProviders(using: any, provider: string, exactMatch: boolean): any[]
    
参数
using any

要搜索的根元素

The root element to search from

provider string

绑定变量的名称

The name of binding variable

exactMatch boolean

是否使用 exactMatch

Whether using exactMatch

返回值

any[]