Closed dwjohnston closed 2 years ago
Duplicate of https://github.com/testing-library/dom-testing-library/issues/567
TL;DR: type="password"
has no role and is therefore not suitable for getByRole
This should be added to the examples in the docs. Many of the examples use a "username" input, but there is no mention of "password" near any of them.
type=password
having no role is a surprise for many users (as indicated by the many issues in this repo) so I think it would be very valuable to provide guidance from veterans/authors as to which query tool fits the philosophy best for this awkward situation that new users are likely to encounter.
Note, I think I answered my own answer. But can someone clarify - when searching for password fields - should I just search by labelText?
This is possibly a regression of https://github.com/testing-library/dom-testing-library/issues/737 ?
Relevant code or config:
What you did:
Try to write tests to assert that password fields exist.
What happened:
These tests fail.
Reproduction:
Full repro here.
https://github.com/dwjohnston/rtl-password
Run
yarn && yarn test
Problem description:
<input type='password'>
should have role 'textbox'Whoops, no it shouldn't - as per the W3 aria spec - it has no role.
Suggested solution: