testing-library / testing-library/dom-testing-library
`getByRole('deletion')` does not return matching `<s>` element
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 3.3k
- Forks
- 474
- PR merge metrics
- No merged PRs in 30d
Description
@testing-library/domversion: 10.4.0- Testing Framework and version: jest 28.1.3
- DOM Environment: jsdom 16.7.0
I believe this is framework/environment agnostic as the same happens using @storybook/test.
Relevant code or config:
// React Component
const StrikethroughText = () => <s>Strikethrough Text</s>
// Test File
screen.getByRole('deletion')
What you did:
Attempted to use a getByRole query to target an <s> element.
What happened:
An error was thrown that an element could not be found.
Reproduction:
https://github.com/tomalexhughes/dom-testing-issue
Problem description:
The HTML ARIA spec states an s element has an implicit role of deletion, and it is not recommended to add this as an explicit role.
However, *ByRole queries only find the element if the role is explicitly set.
Suggested solution:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction and the getByRole query entry point, then inspect how the implicit role for an element is determined. Add a regression test showing that getByRole('deletion') finds the element, and confirm the existing explicit-role behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100