API reference for Angular Material sidenav-testing

import {MatDrawerHarness} from '@angular/material/sidenav/testing';

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

Properties
Name Description

static hostSelector: '.mat-drawer'

The selector for the host element of a MatDrawer instance.

Methods
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
getHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<T>

async
getHarnessOrNull
Parameters

query

HarnessQuery<T>

Returns
Promise<T | null>

getMode

Gets the mode that the drawer is in.

Returns
Promise<'over' | 'push' | 'side'>

getPosition

Gets the position of the drawer inside its container.

Returns
Promise<'start' | 'end'>

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>

isOpen

Whether the drawer is open.

Returns
Promise<boolean>

static
with

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

Parameters

options

DrawerHarnessFilters = {}

Options for filtering which drawer instances are considered a match.

Returns
HarnessPredicate<MatDrawerHarness>

a HarnessPredicate configured with the given options.

Harness for interacting with a standard mat-drawer-container in tests.

Properties
Name Description

static hostSelector: '.mat-drawer-container'

The selector for the host element of a MatDrawerContainer instance.

Methods
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
getContent

Gets the element that has the container's content.

Returns
Promise<MatDrawerContentHarness>

async
getDrawers

Gets drawers that match particular criteria within the container.

Parameters

filter

DrawerHarnessFilters = {}

Optionally filters which chips are included.

Returns
Promise<MatDrawerHarness[]>

async
getHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<T>

async
getHarnessOrNull
Parameters

query

HarnessQuery<T>

Returns
Promise<T | null>

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>

static
with

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

Parameters

options

DrawerContainerHarnessFilters = {}

Options for filtering which container instances are considered a match.

Returns
HarnessPredicate<MatDrawerContainerHarness>

a HarnessPredicate configured with the given options.

Harness for interacting with a standard mat-drawer-content in tests.

Properties
Name Description

static hostSelector: '.mat-drawer-content'

The selector for the host element of a MatDrawerContent instance.

Methods
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
getHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<T>

async
getHarnessOrNull
Parameters

query

HarnessQuery<T>

Returns
Promise<T | null>

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>

static
with

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

Parameters

options

DrawerContentHarnessFilters = {}

Options for filtering which drawer content instances are considered a match.

Returns
HarnessPredicate<MatDrawerContentHarness>

a HarnessPredicate configured with the given options.

Harness for interacting with a standard mat-sidenav-container in tests.

Properties
Name Description

static hostSelector: '.mat-sidenav-container'

The selector for the host element of a MatSidenavContainer instance.

Methods
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
getContent

Gets the element that has the container's content.

Returns
Promise<MatSidenavContentHarness>

async
getHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<T>

async
getHarnessOrNull
Parameters

query

HarnessQuery<T>

Returns
Promise<T | null>

async
getSidenavs

Gets sidenavs that match particular criteria within the container.

Parameters

filter

DrawerHarnessFilters = {}

Optionally filters which chips are included.

Returns
Promise<MatSidenavHarness[]>

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>

static
with

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

Parameters

options

DrawerContainerHarnessFilters = {}

Options for filtering which container instances are considered a match.

Returns
HarnessPredicate<MatSidenavContainerHarness>

a HarnessPredicate configured with the given options.

Harness for interacting with a standard mat-sidenav-content in tests.

Properties
Name Description

static hostSelector: '.mat-sidenav-content'

The selector for the host element of a MatSidenavContent instance.

Methods
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
getHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<T>

async
getHarnessOrNull
Parameters

query

HarnessQuery<T>

Returns
Promise<T | null>

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>

static
with

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

Parameters

options

DrawerContentHarnessFilters = {}

Options for filtering which sidenav content instances are considered a match.

Returns
HarnessPredicate<MatSidenavContentHarness>

a HarnessPredicate configured with the given options.

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

Properties
Name Description

static hostSelector: '.mat-sidenav'

The selector for the host element of a MatSidenav instance.

Methods
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
getHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<T>

async
getHarnessOrNull
Parameters

query

HarnessQuery<T>

Returns
Promise<T | null>

getMode

Gets the mode that the drawer is in.

Returns
Promise<'over' | 'push' | 'side'>

getPosition

Gets the position of the drawer inside its container.

Returns
Promise<'start' | 'end'>

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
isFixedInViewport

Whether the sidenav is fixed in the viewport.

Returns
Promise<boolean>

isOpen

Whether the drawer is open.

Returns
Promise<boolean>

static
with

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

Parameters

options

DrawerHarnessFilters = {}

Options for filtering which sidenav instances are considered a match.

Returns
HarnessPredicate<MatSidenavHarness>

a HarnessPredicate configured with the given options.

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

Properties
Name Description

position: 'start' | 'end'

Only find instances whose side is the given value.

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

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