MCPcopy
hub / github.com/testing-library/dom-testing-library / queryAllByAltText

Function queryAllByAltText

src/queries/alt-text.ts:16–25  ·  view source on GitHub ↗
(
  container,
  alt,
  options: MatcherOptions = {},
)

Source from the content-addressed store, hash-verified

14const VALID_TAG_REGEXP = /^(img|input|area|.+-.+)$/i
15
16const queryAllByAltText: AllByBoundAttribute = (
17 container,
18 alt,
19 options: MatcherOptions = {},
20) => {
21 checkContainerType(container)
22 return queryAllByAttribute('alt', container, alt, options).filter(node =>
23 VALID_TAG_REGEXP.test(node.tagName),
24 )
25}
26
27const getMultipleError: GetErrorFunction<[unknown]> = (c, alt) =>
28 `Found multiple elements with the alt text: ${alt}`

Callers 1

element-queries.jsFile · 0.85

Calls 2

checkContainerTypeFunction · 0.90
queryAllByAttributeFunction · 0.90

Tested by

no test coverage detected