API reference for Angular Material chips-testing

import {MatChipListHarness} from '@angular/material/chips/testing';

Harness for interacting with a standard chip list in tests.

Properties
Name Description

static hostSelector: '.mat-chip-list'

The selector for the host element of a MatChipList instance.

Methods
async
getChips

Gets the list of chips inside the chip list.

Parameters

filter

ChipHarnessFilters = {}

Optionally filters which chips are included.

Returns
Promise<MatChipHarness[]>

async
getInput

Gets the MatChipInput inside the chip list.

Parameters

filter

ChipInputHarnessFilters = {}

Optionally filters which chip input is included.

Returns
Promise<MatChipInputHarness>

getOrientation

Gets whether the orientation of the chip list.

Returns
Promise<'horizontal' | 'vertical'>

async
host

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

Returns
Promise<TestElement>

isDisabled

Gets whether the chip list is disabled.

Returns
Promise<boolean>

isInvalid

Gets whether the chip list is invalid.

Returns
Promise<boolean>

isMultiple

Gets whether the chip list is in multi selection mode.

Returns
Promise<boolean>

isRequired

Gets whether the chip list is required.

Returns
Promise<boolean>

static
with

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

Parameters

options

ChipListHarnessFilters = {}

Options for filtering which chip list instances are considered a match.

Returns
HarnessPredicate<MatChipListHarness>

a HarnessPredicate configured with the given options.

Deprecated
async
selectChips

Selects a chip inside the chip list.

Parameters

filter

ChipHarnessFilters = {}

An optional filter to apply to the child chips. All the chips matching the filter will be selected.

Returns
Promise<void>

Promise that resolves when the action completes.

Harness for interacting with a standard selectable Angular Material chip in tests.

Properties
Name Description

static hostSelector: '.mat-chip'

The selector for the host element of a MatChip instance.

Methods
async
getAllChildLoaders
Parameters

selector

S

Returns
Promise<HarnessLoader[]>

async
getAllHarnesses
Parameters

query

HarnessQuery<T>

Returns
Promise<T[]>

async
getAvatar

Gets the avatar inside a chip.

Parameters

filter

ChipAvatarHarnessFilters = {}

Optionally filters which avatars are included.

Returns
Promise<MatChipAvatarHarness | null>

async
getChildLoader
Parameters

selector

S

Returns
Promise<HarnessLoader>

async
getHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<T>

async
getHarnessOrNull
Parameters

query

HarnessQuery<T>

Returns
Promise<T | null>

async
getRemoveButton

Gets the remove button inside of a chip.

Parameters

filter

ChipRemoveHarnessFilters = {}

Optionally filters which remove buttons are included.

Returns
Promise<MatChipRemoveHarness>

async
getText

Gets the text of the chip.

Returns
Promise<string>

async
hasHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<boolean>

async
host

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

Returns
Promise<TestElement>

async
isDisabled

Whether the chip is disabled.

Returns
Promise<boolean>

async
remove

Removes the given chip. Only applies if it's removable.

Returns
Promise<void>

Promise that resolves when the action completes.

static
with

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

Parameters

options

ChipHarnessFilters = {}

Options for filtering which chip instances are considered a match.

Returns
HarnessPredicate<MatChipHarness>

a HarnessPredicate configured with the given options.

Deprecated
async
deselect

Deselects the given chip. Only applies if it's selectable.

Returns
Promise<void>

Promise that resolves when the action completes.

Deprecated
async
isSelected

Whether the chip is selected.

Returns
Promise<boolean>

Deprecated
async
select

Selects the given chip. Only applies if it's selectable.

Returns
Promise<void>

Promise that resolves when the action completes.

Deprecated
async
toggle

Toggles the selected state of the given chip. Only applies if it's selectable.

Returns
Promise<void>

Promise that resolves when the action completes.

Harness for interacting with a standard Material chip inputs in tests.

Properties
Name Description

static hostSelector: '.mat-chip-input'

Methods
async
blur

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

Returns
Promise<void>

Promise that resolves when the action completes.

async
focus

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

Returns
Promise<void>

Promise that resolves when the action completes.

async
getPlaceholder

Gets the placeholder of the input.

Returns
Promise<string>

async
getValue

Gets the value of the 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 input is disabled.

Returns
Promise<boolean>

async
isFocused

Whether the input is focused.

Returns
Promise<boolean>

async
isRequired

Whether the input is required.

Returns
Promise<boolean>

async
sendSeparatorKey

Sends a chip separator key to the input element.

Parameters

key

string | TestKey

Returns
Promise<void>

Promise that resolves when the action completes.

async
setValue

Sets the value of the input. The value will be set by simulating keypresses that correspond to the given value.

Parameters

newValue

string

Returns
Promise<void>

Promise that resolves when the action completes.

static
with

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

Parameters

options

ChipInputHarnessFilters = {}

Options for filtering which input instances are considered a match.

Returns
HarnessPredicate<MatChipInputHarness>

a HarnessPredicate configured with the given options.

Harness for interacting with a standard Material chip remove button in tests.

Properties
Name Description

static hostSelector: '.mat-chip-remove'

Methods
async
click

Clicks the remove button.

Returns
Promise<void>

Promise that resolves when the action completes.

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 MatChipRemoveHarness that meets certain criteria.

Parameters

options

ChipRemoveHarnessFilters = {}

Options for filtering which input instances are considered a match.

Returns
HarnessPredicate<MatChipRemoveHarness>

a HarnessPredicate configured with the given options.

Properties
Name Description

static hostSelector: '.mat-chip'

The selector for the host element of a selectable chip instance.

Methods
async
deselect

Deselects the given chip. Only applies if it's selectable.

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
getAvatar

Gets the avatar inside a chip.

Parameters

filter

ChipAvatarHarnessFilters = {}

Optionally filters which avatars are included.

Returns
Promise<MatChipAvatarHarness | null>

async
getChildLoader
Parameters

selector

S

Returns
Promise<HarnessLoader>

async
getHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<T>

async
getHarnessOrNull
Parameters

query

HarnessQuery<T>

Returns
Promise<T | null>

async
getRemoveButton

Gets the remove button inside of a chip.

Parameters

filter

ChipRemoveHarnessFilters = {}

Optionally filters which remove buttons are included.

Returns
Promise<MatChipRemoveHarness>

async
getText

Gets the text of the chip.

Returns
Promise<string>

async
hasHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<boolean>

async
host

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

Returns
Promise<TestElement>

async
isDisabled

Whether the chip is disabled.

Returns
Promise<boolean>

async
isSelected

Whether the chip is selected.

Returns
Promise<boolean>

async
remove

Removes the given chip. Only applies if it's removable.

Returns
Promise<void>

Promise that resolves when the action completes.

async
select

Selects the given chip. Only applies if it's selectable.

Returns
Promise<void>

Promise that resolves when the action completes.

async
toggle

Toggles the selected state of the given chip.

Returns
Promise<void>

Promise that resolves when the action completes.

static
with

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

Parameters

options

ChipOptionHarnessFilters = {}

Options for filtering which chip instances are considered a match.

Returns
HarnessPredicate<MatChipOptionHarness>

a HarnessPredicate configured with the given options.

Harness for interacting with a standard selectable chip list in tests.

Properties
Name Description

static hostSelector: '.mat-chip-list'

The selector for the host element of a MatChipList instance.

Methods
async
getChips

Gets the list of chips inside the chip list.

Parameters

filter

ChipOptionHarnessFilters = {}

Optionally filters which chips are included.

Returns
Promise<MatChipOptionHarness[]>

getOrientation

Gets whether the orientation of the chip list.

Returns
Promise<'horizontal' | 'vertical'>

async
host

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

Returns
Promise<TestElement>

isDisabled

Gets whether the chip list is disabled.

Returns
Promise<boolean>

isInvalid

Gets whether the chip list is invalid.

Returns
Promise<boolean>

isMultiple

Gets whether the chip list is in multi selection mode.

Returns
Promise<boolean>

isRequired

Gets whether the chip list is required.

Returns
Promise<boolean>

async
selectChips

Selects a chip inside the chip list.

Parameters

filter

ChipOptionHarnessFilters = {}

An optional filter to apply to the child chips. All the chips matching the filter will be selected.

Returns
Promise<void>

Promise that resolves when the action completes.

static
with

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

Parameters

options

ChipListboxHarnessFilters = {}

Options for filtering which chip list instances are considered a match.

Returns
HarnessPredicate<MatChipListboxHarness>

a HarnessPredicate configured with the given options.

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

Properties
Name Description

text: string | RegExp

Only find instances whose text matches the given value.

Deprecated

selected: boolean

Only find chip instances whose selected state matches the given value.

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

Properties
Name Description

selected: boolean

Only find chip instances whose selected state matches the given value.

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

A set of criteria that can be used to filter selectable chip list instances.

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

Properties
Name Description

placeholder: string | RegExp

Filters based on the placeholder text of the input.

value: string | RegExp

Filters based on the value of the input.

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

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