API reference for Angular Material select-testing

import {MatSelectHarness} from '@angular/material/select/testing';

Harness for interacting with a standard mat-select in tests.

Properties
Name Description

static hostSelector: '.mat-select'

Methods
async
blur

Blurs the select and returns a void promise that indicates when the action is complete.

Returns
Promise<void>

Promise that resolves when the action completes.

async
clickOptions

Clicks the options that match the passed-in filter. If the select is in multi-selection mode all options will be clicked, otherwise the harness will pick the first matching option.

Parameters

filter?

OptionFilters

Returns
Promise<void>

Promise that resolves when the action completes.

async
close

Closes the select's panel.

Returns
Promise<void>

Promise that resolves when the action completes.

async
focus

Focuses the select and returns a void promise that indicates when the action is complete.

Returns
Promise<void>

Promise that resolves when the action completes.

async
getOptionGroups

Gets the groups of options inside the panel.

Parameters

filter?

Omit<OptionGroupFilters, "ancestor">

Returns
Promise<OptionGroup[]>

async
getOptions

Gets the options inside the select panel.

Parameters

filter?

Omit<OptionFilters, "ancestor">

Returns
Promise<Option[]>

async
getValueText

Gets a promise for the select's value text.

Returns
Promise<string>

async
host

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

Returns
Promise<TestElement>

async
isDisabled

Gets a boolean promise indicating if the select is disabled.

Returns
Promise<boolean>

async
isEmpty

Gets a boolean promise indicating if the select is empty (no value is selected).

Returns
Promise<boolean>

async
isFocused

Whether the select is focused.

Returns
Promise<boolean>

async
isMultiple

Gets a boolean promise indicating if the select is in multi-selection mode.

Returns
Promise<boolean>

async
isOpen

Gets whether the select is open.

Returns
Promise<boolean>

async
isRequired

Gets a boolean promise indicating if the select is required.

Returns
Promise<boolean>

async
isValid

Gets a boolean promise indicating if the select is valid.

Returns
Promise<boolean>

async
open

Opens the select's panel.

Returns
Promise<void>

Promise that resolves when the action completes.

static
with

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

Parameters

options

SelectHarnessFilters = {}

Returns
HarnessPredicate<MatSelectHarness>

a HarnessPredicate configured with the given options.

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