-
Notifications
You must be signed in to change notification settings - Fork 399
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
Adjust toBeVisible matcher #263
Comments
I'm hesitant about changing the semantics of Also, can you please share here a more precise approach to check for whatever makes an element invisible but still visible to screen readers? Is it checking the precise set of styles that the And last but not least, visibility detection has been one of the most controversial or confusing features we've released with the matchers in this lib. Relying on things such as what css is applied to an element at any given point is tricky. Mostly because in the test env usually the full css that would normally be available in the app when running is not loaded or even attached to the jsdom document. I wrote more about that here #116 (comment) and especially here #113 (comment). If this would-be feature relies on checking those sets of css it can be tricky for people to actually make it work. |
Correct. My mindset would be to check the computed properties for a strict match.
No worries! I figured there may be hesitation. I think it's the right way to go about it since the element is definitely not visible; however, if it's easier, we could make a new matcher! Maybe
Definitely. Visibility seems to be a rough issue for anything riding a jsdom environment... Perhaps the best way for me to go about this would be to make my own custom matcher 🤷 |
import { isInaccessible } from '@testing-library/dom'; Then you apply the same semantics that e.g. I wouldn't recommend a matcher for visually hidden. Visibility has very little meaning. What you probably want is "perceivable" and for that you're better off with visual regression tools or manual testing. |
This wouldn't be relevant, but your remark about visual regression testing rings true. |
Nice discussion here, and very good points added by @eps1lon. Thanks! |
Describe the feature you'd like:
Many developers leverage a component to render content, but not have it be visible for the sake of accessibility. There are many places where this strategy is recommended, but the most popular one is outlined in the US Government's accessibility documentation. The
.toBeVisible
matcher would assert that any element leveraging these styles IS visible, but I would love to be able to assert that it is NOT visible.Suggested implementation:
Explicitly check for all the properties matching as-is OR the existing logic in the matcher source code.
Describe alternatives you've considered:
🤷
Teachability, Documentation, Adoption, Migration Strategy:
🤷
The text was updated successfully, but these errors were encountered: