You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: extend toBeChecked to support any role that's compatible (#267)
* Get supported roles for toBeChecked via aria-query
Instead of hard coding a list of roles, use information provided by
the `aria-query` package to determine whether an element with a given
role supports the `aria-checked` attribute.
Dynamically generate an error message listing all supported
roles. Make error message expectations more fuzzy to prevent test
failures if the list of supported roles should ever change.
'only inputs with type="checkbox" or type="radio" or elements with role="checkbox", role="radio" or role="switch" and a valid aria-checked attribute can be used with .toBeChecked(). Use .toHaveValue() instead',
'only inputs with type="checkbox" or type="radio" or elements with role="checkbox", role="radio" or role="switch" and a valid aria-checked attribute can be used with .toBeChecked(). Use .toHaveValue() instead',
'only inputs with type="checkbox" or type="radio" or elements with role="checkbox", role="radio" or role="switch" and a valid aria-checked attribute can be used with .toBeChecked(). Use .toHaveValue() instead',
'only inputs with type="checkbox" or type="radio" or elements with role="checkbox", role="radio" or role="switch" and a valid aria-checked attribute can be used with .toBeChecked(). Use .toHaveValue() instead',
@@ -22,7 +23,7 @@ export function toBeChecked(element) {
22
23
return{
23
24
pass: false,
24
25
message: ()=>
25
-
'only inputs with type="checkbox" or type="radio" or elements with role="checkbox", role="radio" or role="switch" and a valid aria-checked attribute can be used with .toBeChecked(). Use .toHaveValue() instead',
26
+
`only inputs with type="checkbox" or type="radio" or elements with ${supportedRolesSentence()}and a valid aria-checked attribute can be used with .toBeChecked(). Use .toHaveValue() instead`,
26
27
}
27
28
}
28
29
@@ -44,3 +45,18 @@ export function toBeChecked(element) {
0 commit comments