• Overview
@angular/cdk/testing/testbed

TestbedHarnessEnvironment

Class

A HarnessEnvironment implementation for Angular's Testbed.

API

  
    class TestbedHarnessEnvironment extends HarnessEnvironment<Element> {}
  
  

constructor

TestbedHarnessEnvironment
@paramrawRootElementElement
@param_fixtureComponentFixture<unknown>
@paramoptionsTestbedHarnessEnvironmentOptions | undefined

forceStabilize

Promise<void>

Flushes change detection and async tasks captured in the Angular zone. In most cases it should not be necessary to call this manually. However, there may be some edge cases where it is needed to fully flush animation events.

@returnsPromise<void>

waitForTasksOutsideAngular

Promise<void>

Waits for all scheduled or running async tasks to complete. This allows harness authors to wait for async tasks outside of the Angular zone.

@returnsPromise<void>

getDocumentRoot

Element

Gets the root element for the document.

@returnsElement

createTestElement

TestElement

Creates a TestElement from a raw element.

@paramelementElement
@returnsTestElement

createEnvironment

HarnessEnvironment<Element>

Creates a HarnessLoader rooted at the given raw element.

@paramelementElement
@returnsHarnessEnvironment<Element>

getAllRawElements

Promise<Element[]>

Gets a list of all elements matching the given selector under this environment's root element.

@paramselectorstring
@returnsPromise<Element[]>

loader

HarnessLoader

Creates a HarnessLoader rooted at the given fixture's root element.

@paramfixtureComponentFixture<unknown>
@paramoptionsTestbedHarnessEnvironmentOptions | undefined
@returnsHarnessLoader

documentRootLoader

HarnessLoader

Creates a HarnessLoader at the document root. This can be used if harnesses are located outside of a fixture (e.g. overlays appended to the document body).

@paramfixtureComponentFixture<unknown>
@paramoptionsTestbedHarnessEnvironmentOptions | undefined
@returnsHarnessLoader

getNativeElement

Element

Gets the native DOM element corresponding to the given TestElement.

@paramelTestElement
@returnsElement

harnessForFixture

Promise<T>

Creates an instance of the given harness type, using the fixture's root element as the harness's host element. This method should be used when creating a harness for the root element of a fixture, as components do not have the correct selector when they are created as the root of the fixture.

@paramfixtureComponentFixture<unknown>
@paramharnessTypeComponentHarnessConstructor<T>
@paramoptionsTestbedHarnessEnvironmentOptions | undefined
@returnsPromise<T>
Jump to details