dom-testing-library icon indicating copy to clipboard operation
dom-testing-library copied to clipboard

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

Open rdwoodring opened this issue 1 year ago • 4 comments

  • @testing-library/dom version: 9.3.4
  • @testing-libraray/react version: 14.2.1
  • Testing Framework and version: jest 27.5.1
  • DOM Environment: jsdom 16.7.0

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:

rdwoodring avatar Feb 08 '24 19:02 rdwoodring

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!

MatanBobi avatar Feb 08 '24 19:02 MatanBobi

@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

rdwoodring avatar Feb 09 '24 01:02 rdwoodring

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!

MatanBobi avatar Feb 09 '24 11:02 MatanBobi

Ok, let me see what I can do.

rdwoodring avatar Feb 10 '24 01:02 rdwoodring

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).

jlp-craigmorten avatar Apr 10 '24 13:04 jlp-craigmorten

Thanks @jlp-craigmorten :)

MatanBobi avatar Apr 10 '24 13:04 MatanBobi