Skip to content
masterclass Buddy

React Testing Library · Function

getNodeText

getNodeText returns an element's text with extra whitespace removed. For submit and button inputs, it reads the displayed value.

Last updated

Syntax

getNodeText(node: HTMLElement): string

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

Subscribe
  • getByText
  • queryByText

Source: Custom Queries | Testing Library. Checked 2026-11-03.