Skip to content

getByRole does not work with "term" #703

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

Closed
supervanya opened this issue Jul 16, 2020 · 10 comments · Fixed by #1058
Closed

getByRole does not work with "term" #703

supervanya opened this issue Jul 16, 2020 · 10 comments · Fixed by #1058
Labels
bug Something isn't working

Comments

@supervanya
Copy link

supervanya commented Jul 16, 2020

  • Testing Framework and version:

@testing-library/react: 10.4.4

jest: 24.9.0

  • DOM Environment:

@testing-library/jest-dom: ^5.11.0

Relevant code or config:

const dt = screen.getAllByRole("term");

What you did:

I was trying to get dt elements by role ("term")

What happened:

I am getting an error:
Unable to find an accessible element with the role "term"
(more info in the sandbox)

Reproduction:

https://codesandbox.io/s/react-testing-library-demo-skxjh?file=/src/__tests__/hello.js

Problem description:

term is one of the accessible roles as stated on w3 here
It used to work in the @testing-library/react: 10.2.1 but broke in 10.3.0

Suggested solution:

I am a pretty new front end developer and unfortunately don't have a solution but I would really appreciate any help and I could possibly try to create a PR (never done this before though)

@timdeschryver
Copy link
Member

#683 should fix this.

@timdeschryver
Copy link
Member

Closed by #683 .
Could you try it out @supervanya ?

@alanhchoi
Copy link

It's still not working on 10.4.7 https://codesandbox.io/s/react-testing-library-demo-zmkvi?file=/src/__tests__/hello.js

@marcosvega91
Copy link
Member

I have opened a PR on A11yance/aria-query#70

@timdeschryver
Copy link
Member

Thanks @alanhchoi and @marcosvega91.

@alanhchoi
Copy link

alanhchoi commented Aug 21, 2020

For anyone who visits here, this is a workaround you can try until the new version of aria-query is released.

Add to package.json:

"resolutions": {
  "**/aria-query": "4.0.2"
}

4.0.2 is the latest version of aria-query without the commit that introduced this bug.
Update package.json and install the packages again. You'll be able to select dt elements with getByRole('term') query.

@nickserv
Copy link
Member

Would it help if we pinned this version in DOM Testing Library for now?

@eps1lon
Copy link
Member

eps1lon commented Aug 22, 2020

Would it help if we pinned this version in DOM Testing Library for now?

For this particular issue, yes. But it would mean we would drop back to ARIA 1.1 instead of 1.2. Just by quantity this would make matters worse. Since you can manually resolve versions I would rather recommend #703 (comment) if term is more important than ARIA 1.2 for you.

@eps1lon
Copy link
Member

eps1lon commented Oct 18, 2021

@all-contributors add @supervanya for bug

@allcontributors
Copy link
Contributor

@eps1lon

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants