React Testing Library · Function
getByRole
getByRole finds one element by its accessible role, including roles supplied by semantic HTML. Use options such as name, state, heading level, or value to narrow the match.
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 } }): HTMLElementIn-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
queryByRolegetAllByRolequeryAllByRolefindByRolefindAllByRolescreenwithingetByLabelText