Ir para o conteúdo principal

ByPlaceholderText

[Tradução Beta Não Oficial]

Esta página foi traduzida por PageTurner AI (beta). Não é oficialmente endossada pelo projeto. Encontrou um erro? Reportar problema →

getByPlaceholderText, queryByPlaceholderText, getAllByPlaceholderText, queryAllByPlaceholderText, findByPlaceholderText, findAllByPlaceholderText

API

getByPlaceholderText(
// If you're using `screen`, then skip the container argument:
container: HTMLElement,
text: TextMatch,
options?: {
exact?: boolean = true,
normalizer?: NormalizerFn,
}): HTMLElement

Esta função buscará todos os elementos com um atributo placeholder e encontrará um que corresponda ao TextMatch fornecido.

<input placeholder="Username" />
import {screen} from '@testing-library/dom'

const inputNode = screen.getByPlaceholderText('Username')

Nota

Um placeholder não é um bom substituto para uma label, então você deve usar preferencialmente getByLabelText em seu lugar.

Opções

Opções de TextMatch