A HarnessEnvironment implementation for Angular's Testbed.
API
class TestbedHarnessEnvironment extends HarnessEnvironment<Element> {
protected constructor(rawRootElement: Element, _fixture: ComponentFixture<unknown>, options?: TestbedHarnessEnvironmentOptions | undefined): TestbedHarnessEnvironment;
forceStabilize(): Promise<void>;
waitForTasksOutsideAngular(): Promise<void>;
protected getDocumentRoot(): Element;
protected createTestElement(element: Element): TestElement;
protected createEnvironment(element: Element): HarnessEnvironment<Element>;
protected getAllRawElements(selector: string): Promise<Element[]>;
static loader(fixture: ComponentFixture<unknown>, options?: TestbedHarnessEnvironmentOptions | undefined): HarnessLoader;
static documentRootLoader(fixture: ComponentFixture<unknown>, options?: TestbedHarnessEnvironmentOptions | undefined): HarnessLoader;
static getNativeElement(el: TestElement): Element;
static harnessForFixture<T extends ComponentHarness>(fixture: ComponentFixture<unknown>, harnessType: ComponentHarnessConstructor<T>, options?: TestbedHarnessEnvironmentOptions | undefined): Promise<T>;
}
constructor
TestbedHarnessEnvironmentElement
TestbedHarnessEnvironment
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.
Promise<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.
This only works when Zone.js is present and patches are applied to the test framework by zone.js/testing (Jasmine and Jest only) or another script.
Promise<void>
getDocumentRoot
ElementGets the root element for the document.
Element
createTestElement
TestElementCreates a TestElement from a raw element.
Element
TestElement
createEnvironment
HarnessEnvironment<Element>Creates a HarnessLoader rooted at the given raw element.
Element
HarnessEnvironment<Element>
getAllRawElements
Promise<Element[]>Gets a list of all elements matching the given selector under this environment's root element.
string
Promise<Element[]>
loader
HarnessLoaderCreates a HarnessLoader rooted at the given fixture's root element.
HarnessLoader
documentRootLoader
HarnessLoaderCreates 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).
HarnessLoader
getNativeElement
ElementGets the native DOM element corresponding to the given TestElement.
TestElement
Element
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.
ComponentHarnessConstructor<T>
Promise<T>