API reference for Angular Material core-testing

import {MatOptionHarness} from '@angular/material/core/testing';

Harness for interacting with a mat-option in tests.

Properties
Name Description

static hostSelector: '.mat-option'

Selector used to locate option instances.

Methods
async
click

Clicks the option.

Returns
Promise<void>

Promise that resolves when the action completes.

async
getText

Gets the option's label text.

Returns
Promise<string>

async
host

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

Returns
Promise<TestElement>

async
isActive

Gets whether the option is active.

Returns
Promise<boolean>

async
isDisabled

Gets whether the option is disabled.

Returns
Promise<boolean>

async
isMultiple

Gets whether the option is in multiple selection mode.

Returns
Promise<boolean>

async
isSelected

Gets whether the option is selected.

Returns
Promise<boolean>

static
with

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

Parameters

options

OptionHarnessFilters = {}

Harness for interacting with a mat-optgroup in tests.

Properties
Name Description

static hostSelector: '.mat-optgroup'

Selector used to locate option group instances.

Methods
async
getLabelText

Gets the option group's label text.

Returns
Promise<string>

async
getOptions

Gets the options that are inside the group.

Parameters

filter

OptionHarnessFilters = {}

Returns
Promise<MatOptionHarness[]>

async
host

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

Returns
Promise<TestElement>

async
isDisabled

Gets whether the option group is disabled.

Returns
Promise<boolean>

static
with

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

Parameters

options

OptgroupHarnessFilters = {}

Properties
Name Description

isSelected: boolean

text: string | RegExp

Properties
Name Description

labelText: string | RegExp