Skip to content

ByRole doesn't find SVG's graphics-document role #1131

@CreativeTechGuy

Description

@CreativeTechGuy
  • @testing-library/dom version: 8.13.0
  • Testing Framework and version: N/A
  • DOM Environment: jsdom@19

Relevant code or config:

getByRole("graphics-document")

What you did:

I have an SVG element in the page which I'm trying to select by its role.

What happened:

In the W3 role documentation linked from the ByRole docs, it lists the implicit role for an SVG tag as graphics-document. This value isn't included in the TypeScript definitions, but more importantly it isn't supported at runtime either.

Reproduction:

https://codesandbox.io/s/react-testing-library-demo-forked-rd79zt?file=/src/__tests__/hello.js

Problem description:

The only way to query for an SVG is via querySelector which goes against the recommendations of the library.

Suggested solution:

Support the aria-role as a selector as the documentation would suggest is possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions