Skip to content
masterclass Buddy

React Testing Library · Function

getRoles

getRoles groups elements in a DOM tree by their implicit ARIA role. It returns an object where each role name maps to an array of matching elements.

Last updated

Syntax

getRoles(container)

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

Subscribe
  • getByRole
  • isInaccessible
  • logRoles

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