Skip to content
masterclass Buddy

React Testing Library · Module

getAllByText

Use getByText to find one element whose text matches a string or pattern. React Testing Library exposes the same query through screen or the object returned by render.

Last updated

Syntax

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

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

Subscribe
  • queryByText
  • getAllByText
  • queryAllByText
  • findByText
  • findAllByText
  • screen
  • within
  • render

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