testing-library / testing-playground

Simple and complete DOM testing playground that encourage good testing practices.
https://testing-playground.com
MIT License
788 stars 62 forks source link

Suggesting `getByText` over `getByLabelText` #346

Closed zaicevas closed 1 year ago

zaicevas commented 2 years ago

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 💻

smeijer commented 2 years ago

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

smeijer commented 1 year ago

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.