Skip to content
masterclass Buddy

React Testing Library · Module

queryByLabelText

getByLabelText finds a form control by its label or aria-label. It is useful when a test should interact with a control the way a user identifies it.

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
  • render

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