Skip to content
masterclass Buddy

React Testing Library · Function

queryByText

queryByText checks for an element by its text. It returns the element, null for no match, and throws when multiple elements match.

Last updated

Syntax

queryByText(text, options?)

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

Subscribe
  • getByText
  • getAllByText
  • queryAllByText
  • findByText
  • findAllByText
  • screen
  • within

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