Description
Describe the bug
The example for ByAltText
uses the following example markup:
<img alt="Incredibles 2 Poster" src="/incredibles-2.png" />
The examples pass /incredibles.*png$/i
to getByAltText
, which seems incorrect. If we're trying to find the element by the value of the alt
attribute, why would we include png$
in the regular expression, since that's part of the src
attribute and not the alt
attribute?
To Reproduce
Steps to reproduce the behavior:
- Go to https://testing-library.com/docs/dom-testing-library/api-queries#byalttext
- Scroll down to the
ByAltText
example, if it isn't already visible - Look at the example code
Expected behavior
I would expect the example to use "Incredibles 2 Poster", /incredibles/i
, or something without the "png" as the argument to getByAltText
.
If /incredibles.*png$/i
is somehow correct, then perhaps a note explaining why that works would be helpful.
Desktop (please complete the following information):
N/A
Smartphone (please complete the following information):
N/A
Additional context
I haven't used this library yet, so maybe /incredibles.*png$/i
is perfectly valid here. If it is, it is confusing, though.