-
Notifications
You must be signed in to change notification settings - Fork 469
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
ByRole: Constrain API further #1202
Comments
Not dropping the |
Closed in #1211 |
Sorry to dig up a closed issue, but we've just upgraded to the version with this fix in, and this query no longer works. Maybe we're abusing it and there's a better way, but I can't find any suggestions from the docs? We use this to wait for a modal with a given string to appear const modal = await screen.findByRole(
(content, element) => {
return (
content === 'dialog' &&
within(element as HTMLElement).queryByText(title) !== null
)
} Just in case anyone else has something like this, we've reverted to the lower-level: const modal = await waitFor(() => {
const foundModal = screen
.getAllByRole('dialog')
.find((dialog) => within(dialog).queryByText(title) !== null)
if (!foundModal) {
throw new Error(`Cannot find Modal with "${title}"`)
}
return foundModal
}) |
Describe the feature you'd like:
As part of https://gist.github.com/bvaughn/d3c8b8842faf2ac2439bb11773a19cec I'm revisiting a lot of selector APIs from different libraries.
The API of
ByRole
stood out with regard to role selection and its options.Suggested implementation:
role
tostring
match fallback roles (e.g.Leaving for now. Not so clear what's the best default herebyRole('none') === byRole('presentation')
in<div role="none presentation" />
exact
optionnormalizer
optionDescribe alternatives you've considered:
Document concrete use cases (motivated by real-world tests). If you have some, please let me know.
Teachability, Documentation, Adoption, Migration Strategy:
We can document fallback role matching in a footnote. I expect that most queries will not be concerned with fallback roles.
Constraining the API makes teaching this query easier.
The text was updated successfully, but these errors were encountered: