Skip to content
masterclass Buddy

React Testing Library · Function

getByLabelText

getByLabelText finds a form control through its label text or aria-label. It is useful for testing form fields as users identify them.

Last updated

Syntax

getByLabelText(container: HTMLElement, text: TextMatch, options?: { selector?: string; exact?: boolean; normalizer?: NormalizerFn }): HTMLElement

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

Subscribe
  • queryByLabelText
  • getAllByLabelText
  • queryAllByLabelText
  • findByLabelText
  • findAllByLabelText
  • getByRole
  • screen

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