API reference for Angular Material expansion-testing

import {MatAccordionHarness} from '@angular/material/expansion/testing';

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

Properties
Name Description

static hostSelector: '.mat-accordion'

Methods
async
getExpansionPanels

Gets all expansion panels which are part of the accordion.

Parameters

filter

ExpansionPanelHarnessFilters = {}

Returns
Promise<MatExpansionPanelHarness[]>

async
host

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

Returns
Promise<TestElement>

async
isMulti

Whether the accordion allows multiple expanded panels simultaneously.

Returns
Promise<boolean>

static
with

Gets a HarnessPredicate that can be used to search for an accordion with specific attributes.

Parameters

options

AccordionHarnessFilters = {}

Returns
HarnessPredicate<MatAccordionHarness>

a HarnessPredicate configured with the given options.

Harness for interacting with a standard mat-expansion-panel in tests.

Properties
Name Description

static hostSelector: '.mat-expansion-panel'

Methods
async
blur

Blurs the panel.

Returns
Promise<void>

Promise that resolves when the action completes.

async
collapse

Collapses the expansion panel if expanded.

Returns
Promise<void>

Promise that resolves when the action completes.

async
expand

Expands the expansion panel if collapsed.

Returns
Promise<void>

Promise that resolves when the action completes.

async
focus

Focuses the panel.

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
getChildLoader
Parameters

selector

S

Returns
Promise<HarnessLoader>

async
getDescription

Gets the description text of the panel.

Returns
Promise<string | null>

Description text or null if no description is set up.

async
getHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<T>

async
getTextContent

Gets the text content of the panel.

Returns
Promise<string>

async
getTitle

Gets the title text of the panel.

Returns
Promise<string | null>

Title text or null if no title is set up.

async
getToggleIndicatorPosition

Gets the position of the toggle indicator.

Returns
Promise<'before' | 'after'>

async
hasToggleIndicator

Whether the panel has a toggle indicator displayed.

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 panel is disabled.

Returns
Promise<boolean>

async
isExpanded

Whether the panel is expanded.

Returns
Promise<boolean>

async
isFocused

Whether the panel is focused.

Returns
Promise<boolean>

async
toggle

Toggles the expanded state of the panel by clicking on the panel header. This method will not work if the panel is disabled.

Returns
Promise<void>

Promise that resolves when the action completes.

static
with

Gets a HarnessPredicate that can be used to search for an expansion-panel with specific attributes.

Parameters

options

ExpansionPanelHarnessFilters = {}

Returns
HarnessPredicate<MatExpansionPanelHarness>

a HarnessPredicate configured with the given options.

Deprecated
async
getHarnessLoaderForContent

Gets a HarnessLoader that can be used to load harnesses for components within the panel's content area.

Returns
Promise<HarnessLoader>

Properties
Name Description

content: string | RegExp

description: string | RegExp | null

disabled: boolean

expanded: boolean

title: string | RegExp | null