testing-library / testing-library/dom-testing-library

`getByRole('deletion')` does not return matching `<s>` element

Open
#1,351 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
3.3k
Forks
474
PR merge metrics
No merged PRs in 30d

Description

  • @testing-library/dom version: 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.