testing-library / react-testing-library

🐐 Simple and complete React DOM testing utilities that encourage good testing practices.

Home Page:https://testing-library.com/react

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

byRole does not work with implicit searchbox role due to aria-query update

aaronhargrove-grub opened this issue · comments

  • @testing-library/react version: 12.1.5 - but affects any version that pulls in aria-query@^5
  • Testing Framework and version: jest@^26.x
  • DOM Environment: jsdom

Relevant code or config:

<input type="search" ... />
const searchBox = await screen.findByRole('searchbox');

What you did:

Expected searchBox to be defined

What happened:

It could not find the input with the implicit searchbox role

Reproduction:

Is reproducible where the RTL dom (or jest-dom) package pulls in aria-query@^5.0.0

Problem description:

RTL is pulling in aria-query, which recently released an update (5.2.0 and up) which breaks the ability to get a search input by its implicit aria-role, which breaks existing tests without updating any RTL packages directly.

Suggested solution:

It appears this was not intentional and is just a bug. Could lock off the package in a patch release until the aria-query issue is resolved

Hi @aaronhargrove-grub!
Thanks for opening this one.
We have released a patch version where we pinned aria-query a few hours ago. Can you please re-install and see that the issue doesn't reproduce anymore?
Thanks.

Ahh, I must've missed, thanks!

Sorry I closed too early without checking the packages. I saw the patch was only on @testing-library/dom v9. Is it possible to patch @testing-library/dom v8 as well? Without v8 patched, all @testing-library/react v12 consumers will still have the unpinned version

Hey, I've seen a different getByRole issue happening with combobox and img that I've been looking at for the past 2 days which started happening out of nowhere for me after I tried moving the code to a different repo.

image

Yep, pinning the version to 5.1.3 on my side worked. Thanks for providing the details in the issue @aaronhargrove-grub

"resolutions": {
    "aria-query": "5.1.3"
},

@aaronhargrove-grub @blvdmitry with the help of @kentcdodds, I've just released version 8.20.1 of @testing-library/dom to npm, can one of you please re-install RTL and see that things are back to normal?

Seems to be working fine, thanks!