Skip to content
masterclass Buddy

React Testing Library · Matcher

toHaveAccessibleDescription

Use getByRole to find an element by its accessible role. It also supports filters such as accessible name, state, level, and value.

Last updated

Syntax

getByRole(container: HTMLElement, role: string, options?: { hidden?: boolean; name?: TextMatch; description?: TextMatch; selected?: boolean; busy?: boolean; checked?: boolean; pressed?: boolean; suggest?: boolean; current?: boolean | string; expanded?: boolean; queryFallbacks?: boolean; level?: number; value?: { min?: number; max?: number; now?: number; text?: TextMatch } }): HTMLElement

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • screen
  • findByRole
  • getAllByRole
  • queryByRole
  • accessible name
  • TextMatch

Source: ByRole | Testing Library. Checked 2026-11-03.