• Overview
@angular/cdk/testing

HarnessLoader

interface

Interface used to load ComponentHarness objects. This interface is used by test authors to instantiate ComponentHarnesses.

API

  
    interface HarnessLoader {}
  
  

getChildLoader

Promise<HarnessLoader>

Searches for an element with the given selector under the current instances's root element, and returns a HarnessLoader rooted at the matching element. If multiple elements match the selector, the first is used. If no elements match, an error is thrown.

@paramselectorstring

The selector for the root element of the new HarnessLoader

@returnsPromise<HarnessLoader>

getAllChildLoaders

Promise<HarnessLoader[]>

Searches for all elements with the given selector under the current instances's root element, and returns an array of HarnessLoaders, one for each matching element, rooted at that element.

@paramselectorstring

The selector for the root element of the new HarnessLoader

@returnsPromise<HarnessLoader[]>

getHarness

Promise<T>

Searches for an instance of the component corresponding to the given harness type under the HarnessLoader's root element, and returns a ComponentHarness for that instance. If multiple matching components are found, a harness for the first one is returned. If no matching component is found, an error is thrown.

@paramqueryHarnessQuery<T>

A query for a harness to create

@returnsPromise<T>

getHarnessOrNull

Promise<T | null>

Searches for an instance of the component corresponding to the given harness type under the HarnessLoader's root element, and returns a ComponentHarness for that instance. If multiple matching components are found, a harness for the first one is returned. If no matching component is found, null is returned.

@paramqueryHarnessQuery<T>

A query for a harness to create

@returnsPromise<T | null>

getAllHarnesses

Promise<T[]>

Searches for all instances of the component corresponding to the given harness type under the HarnessLoader's root element, and returns a list ComponentHarness for each instance.

@paramqueryHarnessQuery<T>

A query for a harness to create

@returnsPromise<T[]>

hasHarness

Promise<boolean>

Searches for an instance of the component corresponding to the given harness type under the HarnessLoader's root element, and returns a boolean indicating if any were found.

@paramqueryHarnessQuery<T>

A query for a harness to create

@returnsPromise<boolean>
Jump to details