Saltar al contenido principal

ByTitle

[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 →

getByTitle, queryByTitle, getAllByTitle, queryAllByTitle, findByTitle, findAllByTitle

API

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

Devuelve el elemento cuyo atributo title coincide.

También detecta elementos title dentro de SVGs.

<span title="Delete" id="2"></span>
<svg>
<title>Close</title>
<g><path /></g>
</svg>
import {screen} from '@testing-library/dom'

const deleteElement = screen.getByTitle('Delete')
const closeElement = screen.getByTitle('Close')

Opciones

Opciones de TextMatch