Skip to content
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

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

Open
tomalexhughes opened this issue Feb 14, 2025 · 0 comments
Open

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

tomalexhughes opened this issue Feb 14, 2025 · 0 comments

Comments

@tomalexhughes
Copy link

tomalexhughes commented Feb 14, 2025

  • @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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant