Skip to content

getByRole should not find the element with user custom and invalid ARIA role. #1192

@mrdulin

Description

@mrdulin

Relevant code or config:

<div role='item'>
  apple
</div>

// query
screen.getByRole('item')

What happened:

The testing playground query the element successfully and told me the div element has an "item" role.

Problem description:

But the "item" role is not a pre-defined ARIA role, so I expect that screen.getByRole('item') should not find the element.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions