Testing

queryByRole

Returns null for no match; throws for more than one match.

Formal Syntax & Structure

react syntaxreact
screen.queryByRole("alert")

Working Example

Example Snippetreact
screen.queryByRole("alert")
React Reference