API reference for Angular Material dialog-testing

import {MatDialogHarness} from '@angular/material/dialog/testing';

Harness for interacting with a standard MatDialog in tests.

Properties
Name Description

static hostSelector: '.mat-dialog-container'

The selector for the host element of a MatDialog instance.

Methods
async
close

Closes the dialog by pressing escape.

Note: this method does nothing if disableClose has been set to true for the dialog.

Returns
Promise<void>

Promise that resolves when the action completes.

async
getAllChildLoaders
Parameters

selector

S

Returns
Promise<HarnessLoader[]>

async
getAllHarnesses
Parameters

query

HarnessQuery<T>

Returns
Promise<T[]>

async
getAriaDescribedby

Gets the value of the dialog's "aria-describedby" attribute.

Returns
Promise<string | null>

async
getAriaLabel

Gets the value of the dialog's "aria-label" attribute.

Returns
Promise<string | null>

async
getAriaLabelledby

Gets the value of the dialog's "aria-labelledby" attribute.

Returns
Promise<string | null>

async
getChildLoader
Parameters

selector

S

Returns
Promise<HarnessLoader>

async
getHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<T>

async
getId

Gets the id of the dialog.

Returns
Promise<string | null>

async
getRole

Gets the role of the dialog.

Returns
Promise<DialogRole | null>

async
host

Gets a Promise for the TestElement representing the host element of the component.

Returns
Promise<TestElement>

static
with

Gets a HarnessPredicate that can be used to search for a MatDialogHarness that meets certain criteria.

Parameters

options

DialogHarnessFilters = {}

Returns
HarnessPredicate<MatDialogHarness>

a HarnessPredicate configured with the given options.

A set of criteria that can be used to filter a list of MatDialogHarness instances.