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
[FEATURE] toBeVisible
to see height: 0
as "not visible"
#450
Comments
toBeVisible
to see height: 0
as "not visible"toBeVisible
to see height: 0
as "not visible"
There are lots of cases where elements with I made a pen to make it more visual: The documentation already talks about what it supports: Explaining why specific cases where Handling all the cases is not complex: it is impossible. If you wanted something like that in JSDOM, they would have to render fonts just to check which size would your element have with text inside. The issue about that is more than 10 years old there: jsdom/jsdom#135 So Testing Library is right to not support Now about your transition: you could use Examples: |
I've decided against I rewrote my code to add a |
Describe the feature you'd like:
I have a component that is both
height: 0
andaria-hidden="true"
.In this case, I would expect
.toBeVisible()
to returnfalse
. The component is both not in the a11y tree nor is it visible to a user'.There is a closed ticket about this same topic: #177
This is true, except I'm correctly using
aria-hidden="true"
, so it's not there.I can't use anything but
height: 0
because of animations. You can't do a sliding animation withoutwidth
orheight
changes. And if I want to hide something from view,height: 0
does it.If I want to do sliding without height changes, then my code needs to be more complex when visually, the item isn't there.
Suggested implementation:
We can't look for only
height: 0
because that doesn't hide it from the accessibility tree; although, ifaria-hidden
istrue
, then , we should be safe checking if the height is0
fortoBeVisible
.Describe alternatives you've considered:
Testing the wrong things
Instead of using
.not.toBeVisible()
, I can look for the styles on the element styles, but this is a hack that shouldn't be used when "visibility" is the semantic definer. I don't care if the height is0
as a user, I care if I can see it or not.Significantly increasing the component's complexity to workaround
@testing-library/jest-dom
transitionend
event (which doesn't work correctly in older Safari versions).hidden
attribute on an element.useEffect
for when the value changes to open and immediately set the local state in that case.hidden
prop to the HTML element and only set it when we're in the local closed state.This code significantly increases complexity:
Teachability, Documentation, Adoption, Migration Strategy:
Add a segment to the docs explaining what qualifies for
toBeVisible
as notaria-hidden="true"
&height: 0
.The text was updated successfully, but these errors were encountered: