React Testing Library · Function
getByTestId
getByTestId finds an element by its test ID, usually the data-testid attribute. Use it after semantic queries such as role or text do not fit.
Last updated
Syntax
getByTestId(container: HTMLElement, text: TextMatch, options?: { exact?: boolean; normalizer?: NormalizerFn }): HTMLElementIn-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
screenqueryByTestIdgetAllByTestIdqueryAllByTestIdfindByTestIdfindAllByTestIdwithinconfigure