API reference for Angular Material stepper-testing

import {MatStepperHarness} from '@angular/material/stepper/testing';

Harness for interacting with a standard Material stepper in tests.

Properties
Name Description

static hostSelector: '.mat-stepper-horizontal, .mat-stepper-vertical'

The selector for the host element of a MatStepper instance.

Methods
async
getOrientation

Gets the orientation of the stepper.

Returns
Promise<StepperOrientation>

async
getSteps

Gets the list of steps in the stepper.

Parameters

filter

StepHarnessFilters = {}

Returns
Promise<MatStepHarness[]>

async
host

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

Returns
Promise<TestElement>

async
selectStep

Selects a step in this stepper.

Parameters

filter

StepHarnessFilters = {}

Returns
Promise<void>

Promise that resolves when the action completes.

static
with

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

Parameters

options

StepperHarnessFilters = {}

Returns
HarnessPredicate<MatStepperHarness>

a HarnessPredicate configured with the given options.

Harness for interacting with a standard Angular Material step in tests.

Properties
Name Description

static hostSelector: '.mat-step-header'

The selector for the host element of a MatStep instance.

Methods
async
getAllChildLoaders
Parameters

selector

S

Returns
Promise<HarnessLoader[]>

async
getAllHarnesses
Parameters

query

HarnessQuery<T>

Returns
Promise<T[]>

async
getAriaLabel

Gets the aria-label of the step.

Returns
Promise<string | null>

async
getAriaLabelledby

Gets the value of the aria-labelledby attribute.

Returns
Promise<string | null>

async
getChildLoader
Parameters

selector

S

Returns
Promise<HarnessLoader>

async
getHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<T>

async
getLabel

Gets the label of the step.

Returns
Promise<string>

async
getRootHarnessLoader
Returns
Promise<HarnessLoader>

async
hasErrors

Whether the step is currently showing its error state. Note that this doesn't mean that there are or aren't any invalid form controls inside the step, but that the step is showing its error-specific styling which depends on there being invalid controls, as well as the ErrorStateMatcher determining that an error should be shown and that the showErrors option was enabled through the STEPPER_GLOBAL_OPTIONS injection token.

Returns
Promise<boolean>

async
host

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

Returns
Promise<TestElement>

async
isCompleted

Whether the step has been filled out.

Returns
Promise<boolean>

async
isOptional

Whether the step is optional.

Returns
Promise<boolean>

async
isSelected

Whether the step is selected.

Returns
Promise<boolean>

async
select

Selects the given step by clicking on the label. The step may not be selected if the stepper doesn't allow it (e.g. if there are validation errors).

Returns
Promise<void>

Promise that resolves when the action completes.

static
with

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

Parameters

options

StepHarnessFilters = {}

Returns
HarnessPredicate<MatStepHarness>

a HarnessPredicate configured with the given options.

Harness for interacting with a standard Angular Material stepper next button in tests.

Properties
Name Description

static hostSelector: '.mat-stepper-next'

The selector for the host element of a MatStep instance.

Methods
click

Clicks the button.

Returns
Promise<void>

getText

Gets the text of the button.

Returns
Promise<string>

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

Parameters

options

StepperButtonHarnessFilters = {}

Returns
HarnessPredicate<MatStepperNextHarness>

a HarnessPredicate configured with the given options.

Harness for interacting with a standard Angular Material stepper previous button in tests.

Properties
Name Description

static hostSelector: '.mat-stepper-previous'

The selector for the host element of a MatStep instance.

Methods
click

Clicks the button.

Returns
Promise<void>

getText

Gets the text of the button.

Returns
Promise<string>

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

Parameters

options

StepperButtonHarnessFilters = {}

Returns
HarnessPredicate<MatStepperPreviousHarness>

a HarnessPredicate configured with the given options.

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

Properties
Name Description

completed: boolean

Only find completed steps.

invalid: boolean

Only find steps that have errors.

label: string | RegExp

Only find instances whose label matches the given value.

selected: boolean

Only find steps with the given selected state.

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

Properties
Name Description

orientation: StepperOrientation

Only find instances whose orientation matches the given value.

A set of criteria that can be used to filter a list of MatStepperNextHarness and MatStepperPreviousHarness instances.

Properties
Name Description

text: string | RegExp

Only find instances whose text matches the given value.