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
I have tried to use 'toBeVisible' matcher to check if a certain element is visible for the user or not, and does not work as I expected. As far as I see in the code, it just takes into account the inline styles for the element instead of getting computed styles of the element. So, in my Angular project, if the stylesheet of a component says that element is hidden by setting display: none, this matcher still says that element is visible because el.style.display property does not return the real display value.
To be honest, I think it is an issue, but I prefer discussing it.
This is the actual implementation that Spectator does:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have tried to use 'toBeVisible' matcher to check if a certain element is visible for the user or not, and does not work as I expected. As far as I see in the code, it just takes into account the inline styles for the element instead of getting computed styles of the element. So, in my Angular project, if the stylesheet of a component says that element is hidden by setting
display: none
, this matcher still says that element is visible becauseel.style.display
property does not return the real display value.To be honest, I think it is an issue, but I prefer discussing it.
This is the actual implementation that Spectator does:
spectator/projects/spectator/src/lib/matchers.ts
Line 412 in 0cf5a6d
And this is the testing library implementation, which it makes more sense, as far as I understand:
https://github.com/testing-library/jest-dom/blob/af1845383ee2cba007f43460104f73409e7618ac/src/to-be-visible.js
Beta Was this translation helpful? Give feedback.
All reactions