API reference for Angular Material autocomplete-testing

import {MatAutocompleteHarness} from '@angular/material/autocomplete/testing';

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

Properties
Name Description

static hostSelector: '.mat-autocomplete-trigger'

The selector for the host element of a MatAutocomplete instance.

Methods
async
blur

Blurs the autocomplete input.

Returns
Promise<void>

Promise that resolves when the action completes.

async
clear

Clears the input value.

Returns
Promise<void>

Promise that resolves when the action completes.

async
enterText

Enters text into the autocomplete.

Parameters

value

string

Returns
Promise<void>

Promise that resolves when the action completes.

async
focus

Focuses the autocomplete input.

Returns
Promise<void>

Promise that resolves when the action completes.

async
getOptionGroups

Gets the option groups inside the autocomplete panel.

Parameters

filters?

Omit<OptionGroupFilters, "ancestor">

Returns
Promise<OptionGroup[]>

async
getOptions

Gets the options inside the autocomplete panel.

Parameters

filters?

Omit<OptionFilters, "ancestor">

Returns
Promise<Option[]>

async
getValue

Gets the value of the autocomplete input.

Returns
Promise<string>

async
host

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

Returns
Promise<TestElement>

async
isDisabled

Whether the autocomplete input is disabled.

Returns
Promise<boolean>

async
isFocused

Whether the autocomplete input is focused.

Returns
Promise<boolean>

async
isOpen

Whether the autocomplete is open.

Returns
Promise<boolean>

async
selectOption

Selects the first option matching the given filters.

Parameters

filters

OptionFilters

Returns
Promise<void>

Promise that resolves when the action completes.

static
with

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

Parameters

options

AutocompleteHarnessFilters = {}

Options for filtering which autocomplete instances are considered a match.

Returns
HarnessPredicate<MatAutocompleteHarness>

a HarnessPredicate configured with the given options.

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

Properties
Name Description

value: string | RegExp

Only find instances whose associated input element matches the given value.