React Testing Library · Module
queryByAltText
queryByAltText finds one element by its alt attribute and returns null when no element matches. Use it when a missing element is an expected outcome.
Last updated
Syntax
queryByAltText(container: HTMLElement, text: TextMatch, options?: { exact?: boolean; normalizer?: NormalizerFn }): HTMLElement | nullIn-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
getByAltTextgetAllByAltTextqueryAllByAltTextfindByAltTextfindAllByAltTextscreenwithin