queryByText
queryByText is a non-throwing query function in React Testing Library used to locate elements by their visible text. It searches the DOM within a given container (or the global document via the screen object) and returns the first element whose text content matches the provided value. If no element matches, it returns null. If multiple elements match, it returns the first match.
This function is typically used when tests need to verify the presence or absence of text without
Compared with getByText, which throws when there is no match (and often when there are multiple matches),
Usage generally involves providing a text value or a regular expression to match against the element’s visible