API reference for Angular Material tabs-testing

import {MatTabGroupHarness} from '@angular/material/tabs/testing';

Harness for interacting with a standard mat-tab-group in tests.

Properties
Name Description

static hostSelector: '.mat-tab-group'

The selector for the host element of a MatTabGroup instance.

Methods
async
getSelectedTab

Gets the selected tab of the tab group.

Returns
Promise<MatTabHarness>

async
getTabs

Gets the list of tabs in the tab group.

Parameters

filter

TabHarnessFilters = {}

Returns
Promise<MatTabHarness[]>

async
host

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

Returns
Promise<TestElement>

async
selectTab

Selects a tab in this tab group.

Parameters

filter

TabHarnessFilters = {}

Returns
Promise<void>

Promise that resolves when the action completes.

static
with

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

Parameters

options

TabGroupHarnessFilters = {}

Returns
HarnessPredicate<MatTabGroupHarness>

a HarnessPredicate configured with the given options.

Harness for interacting with a standard Angular Material tab-label in tests.

Properties
Name Description

static hostSelector: '.mat-tab-label'

The selector for the host element of a MatTab 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 tab.

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 tab.

Returns
Promise<string>

async
getRootHarnessLoader
Returns
Promise<HarnessLoader>

async
getTextContent

Gets the text content of the tab.

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

Returns
Promise<boolean>

async
isSelected

Whether the tab is selected.

Returns
Promise<boolean>

async
select

Selects the given tab by clicking on the label. Tab cannot be selected if disabled.

Returns
Promise<void>

Promise that resolves when the action completes.

static
with

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

Parameters

options

TabHarnessFilters = {}

Returns
HarnessPredicate<MatTabHarness>

a HarnessPredicate configured with the given options.

Deprecated
async
getHarnessLoaderForContent

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

Returns
Promise<HarnessLoader>

Harness for interacting with a standard mat-tab-nav-bar in tests.

Properties
Name Description

static hostSelector: '.mat-tab-nav-bar'

The selector for the host element of a MatTabNavBar instance.

Methods
async
clickLink

Clicks a link inside the nav bar.

Parameters

filter

TabLinkHarnessFilters = {}

Returns
Promise<void>

Promise that resolves when the action completes.

async
getActiveLink

Gets the active link in the nav bar.

Returns
Promise<MatTabLinkHarness>

async
getLinks

Gets the list of links in the nav bar.

Parameters

filter

TabLinkHarnessFilters = {}

Returns
Promise<MatTabLinkHarness[]>

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

Parameters

options

TabNavBarHarnessFilters = {}

Returns
HarnessPredicate<MatTabNavBarHarness>

a HarnessPredicate configured with the given options.

Harness for interacting with a standard Angular Material tab link in tests.

Properties
Name Description

static hostSelector: '.mat-tab-link'

The selector for the host element of a MatTabLink instance.

Methods
async
click

Clicks on the link.

Returns
Promise<void>

Promise that resolves when the action completes.

async
getLabel

Gets the label of the link.

Returns
Promise<string>

async
host

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

Returns
Promise<TestElement>

async
isActive

Whether the link is active.

Returns
Promise<boolean>

async
isDisabled

Whether the link is disabled.

Returns
Promise<boolean>

static
with

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

Parameters

options

TabLinkHarnessFilters = {}

Returns
HarnessPredicate<MatTabLinkHarness>

a HarnessPredicate configured with the given options.

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

Properties
Name Description

label: string | RegExp

Only find instances whose label matches the given value.

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

Properties
Name Description

selectedTabLabel: string | RegExp

Only find instances whose selected tab label matches the given value.

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

Properties
Name Description

label: string | RegExp

Only find instances whose label matches the given value.

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