Skip to content

@absoluteui/angular/testing

Component harnesses for @angular/cdk/testing: test through the rendered DOM as a user does.

import { AuiButtonHarness, AuiFieldHarness, AuiTextInputHarness, AuiSelectHarness, AuiDatePickerHarness, AuiTabsHarness, AuiDialogHarness, AuiDataTableHeaderHarness, AuiDataTableRowHarness, AuiDataTableHarness, AuiCheckboxHarness, AuiSwitchHarness, AuiRadioGroupHarness, AuiTextareaHarness, AuiNumberInputHarness, AuiComboboxHarness, AuiMultiSelectHarness, AuiSidebarHarness, AuiPaginationHarness, AuiMenuHarness } from '@absoluteui/angular/testing';

harness.

button[auiButton] and a[auiButton].

Method Description
with<T extends AuiButtonHarness>(this: ComponentHarnessConstructor<T>, options?: AuiButtonHarnessFilters | undefined): HarnessPredicate<T>
getText(): Promise<string> Visible text, or the accessible label of an icon-only button.
getVariant(): Promise<string | null>
isDisabled(): Promise<boolean> Native disabled, or aria-disabled (disabled links, loading).
isLoading(): Promise<boolean>
isLink(): Promise<boolean>
click(): Promise<void>
focus(): Promise<void>

harness.

Label, description, validation message, required and disabled state of a form field.

Method Description
getLabel(): Promise<string>
getDescription(): Promise<string | null>
getErrorMessage(): Promise<string | null> The message shown to the user, or null.
isRequired(): Promise<boolean>
isDisabled(): Promise<boolean>
isInvalid(): Promise<boolean>
focus(): Promise<void>
blur(): Promise<void> Leaves the field (marks it touched).

harness.

<aui-text-input>.

Method Description
with<T extends AuiTextInputHarness>(this: ComponentHarnessConstructor<T>, options?: AuiFieldHarnessFilters | undefined): HarnessPredicate<T>
getValue(): Promise<string>
setValue(value: string): Promise<void> Replaces the value by typing, as a user would (input events per key).
getPlaceholder(): Promise<string>

harness.

<aui-select>. The listbox renders inside the host.

Method Description
with<T extends AuiSelectHarness>(this: ComponentHarnessConstructor<T>, options?: AuiFieldHarnessFilters | undefined): HarnessPredicate<T>
getValueText(): Promise<string> The selected option’s label as shown, or the placeholder.
isOpen(): Promise<boolean>
open(): Promise<void>
close(): Promise<void>
getOptions(): Promise<AuiSelectOption[]> Options (opens the listbox first).
selectOption(label: string | RegExp): Promise<void> Opens the listbox and chooses the first option whose label matches.

harness.

<aui-date-picker>: typed segments and the calendar popup.

Method Description
with<T extends AuiDatePickerHarness>(this: ComponentHarnessConstructor<T>, options?: AuiFieldHarnessFilters | undefined): HarnessPredicate<T>
getLabel(): Promise<string>
getSegments(): Promise<string[]> The typed segments in display order, e.g. [‘08’, ‘03’, ‘2026’] in en-GB.
typeDate(date: { year: number; month: number; day: number; }): Promise<void> Types a date into the segments by their accessible names (locale-independent).
isCalendarOpen(): Promise<boolean>
openCalendar(): Promise<void>
getCalendarMonth(): Promise<string> The visible month heading, e.g. “November 2026”.
getDayLabels(): Promise<string[]> Accessible names of the days of the visible month (they name non-working days and holidays).
isDayDisabled(day: number): Promise<boolean>
selectDay(day: number): Promise<void> Chooses a day of the visible month in the calendar.
nextMonth(): Promise<void>
previousMonth(): Promise<void>

harness.

<aui-tabs>.

Method Description
with<T extends AuiTabsHarness>(this: ComponentHarnessConstructor<T>, options?: AuiTabsHarnessFilters | undefined): HarnessPredicate<T>
getLabel(): Promise<string>
getTabLabels(): Promise<string[]>
getSelectedTabLabel(): Promise<string | null>
isTabDisabled(label: string): Promise<boolean>
selectTab(label: string): Promise<void>
getPanelText(): Promise<string> Text of the visible panel.

harness.

An open AbsoluteUI dialog (<aui-dialog> or AuiDialogService). Dialogs render in the body layer: load it with TestbedHarnessEnvironment.documentRootLoader(fixture).

Method Description
with<T extends AuiDialogHarness>(this: ComponentHarnessConstructor<T>, options?: AuiDialogHarnessFilters | undefined): HarnessPredicate<T>
getTitle(): Promise<string>
getDescription(): Promise<string | null>
getBodyText(): Promise<string>
getRole(): Promise<string> dialog or alertdialog.
getActionLabels(): Promise<string[]>
clickAction(label: string): Promise<void>
getFocusedText(): Promise<string | null> Text of the element that has focus inside the dialog, or null.
close(): Promise<void>
pressEscape(): Promise<void>

harness.

A column header of <aui-data-table>.

Method Description
getText(): Promise<string>
isSortable(): Promise<boolean>
getSortDirection(): Promise<"ascending" | "descending" | null> The sort direction of the primary sort (aria-sort), or null.
sort(): Promise<void> Activates the sort button (cycles ascending, descending, unsorted).

harness.

A rendered data row of <aui-data-table>.

Method Description
getCellTexts(): Promise<string[]> Cell texts in column order (selection and expander cells are empty strings).
isSelected(): Promise<boolean>
toggleSelection(): Promise<void> Toggles the row’s selection control.
isEditable(columnId: string): Promise<boolean>
isEditing(): Promise<boolean> True while a cell editor is open in this row (for example after an invalid value).
startEdit(columnId: string): Promise<void> Opens a cell editor (the row is rebuilt: query the row again afterwards). No-op while one is open.
commitEdit(value: string): Promise<void> Replaces the open editor’s text and commits with Enter (the row is rebuilt: query it again).

harness.

<aui-data-table>: rows are the rendered data rows of the current page (or virtual window).

Method Description
with<T extends AuiDataTableHarness>(this: ComponentHarnessConstructor<T>, options?: AuiDataTableHarnessFilters | undefined): HarnessPredicate<T>
getCaption(): Promise<string>
getHeaders(): Promise<AuiDataTableHeaderHarness[]>
getHeaderTexts(): Promise<string[]>
getHeader(text: string): Promise<AuiDataTableHeaderHarness>
getRows(): Promise<AuiDataTableRowHarness[]>
getCellTexts(): Promise<string[][]> Cell texts of every rendered row.
getSort(): Promise<{ column: string; direction: "ascending" | "descending"; } | null> The primary sort, or null.
sortBy(header: string): Promise<void>
search(text: string): Promise<void> Types into the search field and presses Enter, which applies it without the typing delay.
editCell(rowIndex: number, columnId: string, value: string): Promise<string | null> Opens the editor of a cell (rendered row index, column id), replaces its text, and commits with Enter. Returns the message shown for an invalid value (the editor stays open), or null.
getEditError(): Promise<string | null> The message of an open cell editor (invalid value), or null.
goToPage(target: number | "next" | "previous" | "first" | "last"): Promise<void> Moves to another page through the pager.

harness.

<aui-checkbox>.

Method Description
with<T extends AuiCheckboxHarness>(this: ComponentHarnessConstructor<T>, options?: AuiFieldHarnessFilters | undefined): HarnessPredicate<T>
isChecked(): Promise<boolean>
isIndeterminate(): Promise<boolean>
toggle(): Promise<void>
check(): Promise<void>
uncheck(): Promise<void>

harness.

<aui-switch>.

Method Description
with<T extends AuiSwitchHarness>(this: ComponentHarnessConstructor<T>, options?: AuiFieldHarnessFilters | undefined): HarnessPredicate<T>
isChecked(): Promise<boolean>
toggle(): Promise<void>

harness.

<aui-radio-group>.

Method Description
with<T extends AuiRadioGroupHarness>(this: ComponentHarnessConstructor<T>, options?: AuiFieldHarnessFilters | undefined): HarnessPredicate<T>
getOptionLabels(): Promise<string[]>
getCheckedLabel(): Promise<string | null> Label of the checked option, or null.
isOptionDisabled(label: string): Promise<boolean>
select(label: string): Promise<void>

harness.

<aui-textarea>.

Method Description
with<T extends AuiTextareaHarness>(this: ComponentHarnessConstructor<T>, options?: AuiFieldHarnessFilters | undefined): HarnessPredicate<T>
getValue(): Promise<string>
setValue(value: string): Promise<void>

harness.

<aui-number-input>: typing and the spin button keys.

Method Description
with<T extends AuiNumberInputHarness>(this: ComponentHarnessConstructor<T>, options?: AuiFieldHarnessFilters | undefined): HarnessPredicate<T>
getText(): Promise<string> The text shown (formatted for the locale).
getValue(): Promise<number | null> The value as announced (aria-valuenow), or null when empty.
setText(text: string): Promise<void> Types text and leaves the field, as a user would.
increment(): Promise<void>
decrement(): Promise<void>

harness.

<aui-combobox>: typing, options (static or loaded), choosing.

Method Description
with<T extends AuiComboboxHarness>(this: ComponentHarnessConstructor<T>, options?: AuiFieldHarnessFilters | undefined): HarnessPredicate<T>
getLabel(): Promise<string>
getInputText(): Promise<string>
isOpen(): Promise<boolean>
type(text: string): Promise<void> Replaces the text by typing (filters the options or starts a load).
getOptionLabels(): Promise<string[]> Labels of the options shown.
waitForOptions(timeout?: number | undefined): Promise<string[]> Waits (up to timeout ms) until at least one option is shown: loads are debounced outside Angular’s stability tracking.
selectOption(label: string | RegExp): Promise<void>

harness.

<aui-multi-select>: typing, toggling options, selected chips.

Method Description
with<T extends AuiMultiSelectHarness>(this: ComponentHarnessConstructor<T>, options?: AuiFieldHarnessFilters | undefined): HarnessPredicate<T>
getLabel(): Promise<string>
isOpen(): Promise<boolean>
open(): Promise<void>
close(): Promise<void>
type(text: string): Promise<void> Replaces the text by typing (filters the options or starts a load).
getSelectedLabels(): Promise<string[]> Labels of the selected values (the chips), in selection order.
getOptionLabels(): Promise<string[]> Labels of the options shown (including “Select all” when enabled).
toggleOption(label: string | RegExp): Promise<void> Toggles the option with this label (opens the list first).
removeValue(label: string): Promise<void> Removes a selected value with its chip remove button (not available when read-only or disabled).

harness.

<aui-sidebar>.

Method Description
with<T extends AuiSidebarHarness>(this: ComponentHarnessConstructor<T>, options?: AuiSidebarHarnessFilters | undefined): HarnessPredicate<T>
getLabel(): Promise<string>
getItemLabels(): Promise<string[]> Labels of the visible items (items of collapsed groups are hidden).
getCurrentLabel(): Promise<string | null> Label of the current item (aria-current="page"), or null.
click(label: string): Promise<void> Activates an item or toggles a group, as a click does.
isGroupExpanded(label: string): Promise<boolean>
isCollapsed(): Promise<boolean>
toggleCollapsed(): Promise<void> The collapse button (inline mode, collapsible).

harness.

<aui-pagination>.

Method Description
getCurrentPage(): Promise<number | null>
getPageNumbers(): Promise<number[]> Page numbers shown as buttons (ellipses are not pages).
isDisabled(target: "next" | "previous" | "first" | "last"): Promise<boolean>
goTo(target: number | "next" | "previous" | "first" | "last"): Promise<void>

harness.

button[auiMenu]: the trigger; the menu renders next to it, so items are read from the document.

Method Description
with<T extends AuiMenuHarness>(this: ComponentHarnessConstructor<T>, options?: AuiMenuHarnessFilters | undefined): HarnessPredicate<T>
isOpen(): Promise<boolean>
open(): Promise<void>
close(): Promise<void>
getItems(): Promise<AuiMenuItem[]> Items of the top-level menu (opens it).
select(...path: string[]): Promise<void> Opens the menu and activates the item at path (submenus by their labels).

AuiButtonHarnessFilters

Filters for AuiButtonHarness.with().

interface AuiButtonHarnessFilters extends BaseHarnessFilters {
text?: string | RegExp;
variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger';
}

AuiDataTableHarnessFilters

Filters for AuiDataTableHarness.with().

interface AuiDataTableHarnessFilters extends BaseHarnessFilters {
caption?: string | RegExp;
}

AuiDialogHarnessFilters

Filters for AuiDialogHarness.with().

interface AuiDialogHarnessFilters extends BaseHarnessFilters {
title?: string | RegExp;
}

AuiFieldHarnessFilters

Filters for the form field harnesses (with({ label })).

interface AuiFieldHarnessFilters extends BaseHarnessFilters {
label?: string | RegExp;
}

AuiMenuHarnessFilters

Filters for AuiMenuHarness.with().

interface AuiMenuHarnessFilters extends BaseHarnessFilters {
triggerText?: string | RegExp;
}

AuiMenuItem

A menu item, as the harness reads it.

interface AuiMenuItem {
label: string;
disabled: boolean;
checked: boolean | null;
hasSubmenu: boolean;
}

AuiSelectOption

An option of a Select, as the harness reads it.

interface AuiSelectOption {
label: string;
disabled: boolean;
selected: boolean;
}

AuiSidebarHarnessFilters

Filters for AuiSidebarHarness.with().

interface AuiSidebarHarnessFilters extends BaseHarnessFilters {
label?: string | RegExp;
}

AuiTabsHarnessFilters

Filters for AuiTabsHarness.with().

interface AuiTabsHarnessFilters extends BaseHarnessFilters {
label?: string | RegExp;
}