API reference for Angular Material radio-testing

import {MatRadioGroupHarness} from '@angular/material/radio/testing';

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

Methods
async
checkRadioButton

Checks a radio button in this group.

Parameters

filter

RadioButtonHarnessFilters = {}

An optional filter to apply to the child radio buttons. The first tab matching the filter will be selected.

Returns
Promise<void>

Promise that resolves when the action completes.

async
getCheckedRadioButton

Gets the checked radio-button in a radio-group.

Returns
Promise<MatRadioButtonHarness | null>

async
getCheckedValue

Gets the checked value of the radio-group.

Returns
Promise<string | null>

async
getId

Gets the id of the radio-group.

Returns
Promise<string | null>

async
getName

Gets the name of the radio-group.

Returns
Promise<string | null>

async
getRadioButtons

Gets a list of radio buttons which are part of the radio-group.

Parameters

filter

RadioButtonHarnessFilters = {}

Optionally filters which radio buttons are included.

Returns
Promise<MatRadioButtonHarness[]>

async
host

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

Returns
Promise<TestElement>

Harness for interacting with a standard mat-radio-button in tests.

Methods
async
blur

Blurs the radio-button.

Returns
Promise<void>

Promise that resolves when the action completes.

async
check

Puts the radio-button in a checked state by clicking it if it is currently unchecked, or doing nothing if it is already checked.

Returns
Promise<void>

Promise that resolves when the action completes.

async
focus

Focuses the radio-button.

Returns
Promise<void>

Promise that resolves when the action completes.

async
getId

Gets the radio-button's id.

Returns
Promise<string | null>

async
getLabelText

Gets the radio-button's label text.

Returns
Promise<string>

async
getName

Gets the radio-button's name.

Returns
Promise<string | null>

async
getValue

Gets the value of the radio-button. The radio-button value will be converted to a string.

Note: This means that for radio-button's with an object as a value [object Object] is intentionally returned.

Returns
Promise<string | null>

async
host

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

Returns
Promise<TestElement>

async
isChecked

Whether the radio-button is checked.

Returns
Promise<boolean>

async
isDisabled

Whether the radio-button is disabled.

Returns
Promise<boolean>

async
isRequired

Whether the radio-button is required.

Returns
Promise<boolean>

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

Properties
Name Description

name: string

Only find instances whose name attribute is the given value.

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

Properties
Name Description

label: string | RegExp

Only find instances whose label matches the given value.

name: string

Only find instances whose name attribute is the given value.