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
CSS properties from imported classes are not available within tests, i.e. not contained in the return value of getComputedStyles() for the respective element. Among other things, this prevents jest-dom's toBeVisible() matcher from recognizing an element as hidden when display: none; is set in an imported class.
While I discovered this problem with React, it will probably be framework-independent. This SO question seems to indicate it is also an issue with Vue at least.
#1690 fixes this issue, but Vitest by default doesn't process CSS at all. You will need to enable it via test.css config option. We might want to change the default now, since it changes how your code works 🤔
Describe the bug
CSS properties from imported classes are not available within tests, i.e. not contained in the return value of
getComputedStyles()
for the respective element. Among other things, this preventsjest-dom
'stoBeVisible()
matcher from recognizing an element as hidden whendisplay: none;
is set in an imported class.While I discovered this problem with React, it will probably be framework-independent. This SO question seems to indicate it is also an issue with Vue at least.
Reproduction
See this StackBlitz, which I created from the official vitest/react-testing-library example by adding a third test to
App.test.tsx
.System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: