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
testing-library exposes the isInaccessible function, but using it to test for accessibility leads to a less than ideal testing experience. It would be nice if there was a first-class .toBeAccessible() expectation we could use to check for accessible components.
Suggested implementation:
A simple wrapper around isInaccessible, but with an actually useful error message.
Describe alternatives you've considered:
Alternative 1:
expect(isInaccessible(element)).toBe(false);
Pros: Works without modifying @testing-library/jest-dom
Cons:
Bad error messages ("expected true to be false")
Unclear intent due to double negative ("wait, do we want it to be inaccessible?")
Unnecessarily verbose
Alternative 2:
Write a custom matcher.
Pros: Works without modifying @testing-library/jest-dom
Cons: Hard to make it work cleanly without needing to re-invent functions such as checkHtmlElement
Describe the feature you'd like:
testing-library exposes the
isInaccessible
function, but using it to test for accessibility leads to a less than ideal testing experience. It would be nice if there was a first-class.toBeAccessible()
expectation we could use to check for accessible components.Suggested implementation:
A simple wrapper around
isInaccessible
, but with an actually useful error message.Describe alternatives you've considered:
Alternative 1:
Pros: Works without modifying
@testing-library/jest-dom
Cons:
Alternative 2:
Write a custom matcher.
Pros: Works without modifying
@testing-library/jest-dom
Cons: Hard to make it work cleanly without needing to re-invent functions such as
checkHtmlElement
Teachability, Documentation, Adoption, Migration Strategy:
Due to the simple nature of this matcher the docs should only need the bare minimum of an example and a link to the
isInaccessible
docs.The text was updated successfully, but these errors were encountered: