Skip to content

docs: fix incorrect description of getByAltText #1194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 29, 2022

Conversation

tnyo43
Copy link
Contributor

@tnyo43 tnyo43 commented Dec 26, 2022

issue: #1190

*ByAltText query will not return for <img aria-label="XXX" src="fancy.jpg" /> (see sandbox).

@netlify
Copy link

netlify bot commented Dec 26, 2022

Deploy Preview for testing-library ready!

Name Link
🔨 Latest commit 75de58d
🔍 Latest deploy log https://app.netlify.com/sites/testing-library/deploys/63a96b6957648e000887552c
😎 Deploy Preview https://deploy-preview-1194--testing-library.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Comment on lines -65 to -66
`<img aria-label="fancy image" src="fancy.jpg" />` will be returned for both
`getByAltText('fancy image')` and `getByRole('img', { name: 'fancy image' })`.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I did is just removing this "getByAltText('fancy image')"

Maybe I could correct <img aria-label="fancy image" src="fancy.jpg" /> to <img alt="fancy image" src="fancy.jpg"> as like this comment. I made this change so that the following sentence makes sense.

Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep makes sense. We will probably keep the current implementation since aria-label and alt have different behavior so a dedicated query for just alt makes sense.

@eps1lon eps1lon linked an issue Dec 29, 2022 that may be closed by this pull request
@eps1lon eps1lon merged commit 9925c39 into testing-library:main Dec 29, 2022
@eps1lon
Copy link
Member

eps1lon commented Dec 29, 2022

@all-contributors add @tnyo43 for docs

@allcontributors
Copy link
Contributor

@eps1lon

I've put up a pull request to add @tnyo43! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How does ByAltText query work with aria-label
2 participants