testing-playground icon indicating copy to clipboard operation
testing-playground copied to clipboard

Suggesting `getByText` over `getByLabelText`

Open zaicevas opened this issue 3 years ago • 1 comments

Bug Report 🐛

Suggesting getByText over getByLabelText. As far as I understand, getByLabelText is of higher priority than getByText, according to https://testing-library.com/docs/queries/about/#priority

To Reproduce ✔️

image

Expected behavior 🤔

getByLabelText is suggested

Your Environment 💻

  • browser: Chrome
  • os: Mac

zaicevas avatar Jun 09 '22 09:06 zaicevas

You're right. This must get fixed. Are you able to submit a pull?

smeijer avatar Jun 09 '22 09:06 smeijer

This comes from @testing-library/dom. I believe it's because this function doesn't handle aria-label as a label. I'm not sure if it's a bug, or if it has a deeper accessibility reason, but the issue should be filed/fixed there.

smeijer avatar May 20 '23 14:05 smeijer