Saltar al contenido principal

PorTextoPlaceholder

[Traducción Beta No Oficial]

Esta página fue traducida por PageTurner AI (beta). No está respaldada oficialmente por el proyecto. ¿Encontraste un error? 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

Esto buscará todos los elementos con un atributo placeholder y encontrará uno que coincida con el TextMatch proporcionado.

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

const inputNode = screen.getByPlaceholderText('Username')

Nota

Un placeholder no es un buen sustituto para una etiqueta, por lo que generalmente deberías usar getByLabelText en su lugar.

Opciones

Opciones de TextMatch