Aller au contenu principal

ParTitre

[Traduction Bêta Non Officielle]

Cette page a été traduite par PageTurner AI (bêta). Non approuvée officiellement par le projet. Vous avez trouvé une erreur ? Signaler un problème →

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

Renvoie l'élément qui possède l'attribut title correspondant.

Trouve également un élément title dans un SVG.

<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')

Options

options TextMatch