testing-library / dom-testing-library

🐙 Simple and complete DOM testing utilities that encourage good testing practices.
https://testing-library.com/dom
MIT License
3.28k stars 467 forks source link

`getByRole('insertion')` and `getByRole('deletion')` do not match semantic `<del>` and `<ins>` tags #1288

Closed rdwoodring closed 7 months ago

rdwoodring commented 9 months ago

Relevant code or config:

What you did:

Marking up insertions and deletions using the semantic <ins> and <del> tags and creating assertions to getByRole those semantic elements

What happened:

getByRole('insertion') and getByRole('deletion') throw an error that no accessible roles were found.

Reproduction:

https://github.com/rdwoodring/react-testing-library-ins-del

Problem description:

According to the W3C documentation linked by the testing library docs, <del> and <ins> should have implicit roles of deletion and insertion, respectively. When adding the role explicitly (which is expressly not recommended in the very same W3C documentation), the elements are found correctly.

Suggested solution:

MatanBobi commented 9 months ago

Hi @rdwoodring, thanks for opening this one :) Any chance you can test this against our alpha release? (can be installed using npm install @testing-library/dom@alpha). We've updated the underlying package (aria-query) there. We're still running some tests and I didn't get a chance to push it forwards to a release but having someone else testing that release will really help us. Thanks!

rdwoodring commented 9 months ago

@MatanBobi I just tested it out using npm overrides to force @testing-library/react to use the alpha of @testing-library/dom and it seems that the issue is, indeed, resolved there. Any idea when that'll be released and when it will trickle down into @testing-library/react?

And anything I can do to help?

Thanks

MatanBobi commented 9 months ago

Thanks @rdwoodring, appreciate you taking the time to test it. Currently, I'm out of capacity to test it in some of my projects, that's why we're holding it back. If you can run it on your entire project to see that you're not experiencing any regression it will be extremely valuable. Thanks again!

rdwoodring commented 9 months ago

Ok, let me see what I can do.

jlp-craigmorten commented 7 months ago

v10.0.0 is now live with this update, and looks like react-testing-library v15.0.0 will drop soon, see https://github.com/testing-library/react-testing-library/pull/1295 (and then overrides won't be needed).

MatanBobi commented 7 months ago

Thanks @jlp-craigmorten :)