API reference for Angular Material card-testing

import {MatCardHarness} from '@angular/material/card/testing';

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

Properties
Name Description

static hostSelector: '.mat-card'

The selector for the host element of a MatCard 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
getSubtitleText

Gets the cards's subtitle text.

Returns
Promise<string>

async
getText

Gets all of the card's content as text.

Returns
Promise<string>

async
getTitleText

Gets the cards's title text.

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>

static
with

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

Parameters

options

CardHarnessFilters = {}

Options for filtering which card instances are considered a match.

Returns
HarnessPredicate<MatCardHarness>

a HarnessPredicate configured with the given options.

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

Properties
Name Description

subtitle: string | RegExp

Only find instances whose subtitle matches the given value.

text: string | RegExp

Only find instances whose text matches the given value.

title: string | RegExp

Only find instances whose title matches the given value.