-
Notifications
You must be signed in to change notification settings - Fork 404
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
toHaveStyles always report hover style #594
Comments
I have the same problem!!
|
I have the same issue on Unfortunately, I guess it works only for |
I found that is caused by "getComputedStyle" of JSDOM. |
I have been waiting for the fix for nearly a half year ... |
You could use patch-package first to patch the fix here, no need to wait for nwsapi and jest to release it |
For end-user projects paid for by a commercial customer, in my experience, this will create headaches and tech debt in the future - for yourself if the customer is lucky, but web development companies usually enjoy some amount staff turnover. If a project maintainer is on top of things all the time, and it's a product of love and whatnot, this is okay advice, and perfectly fine to implement in any downstream project or package. So patch-package is a great solution if the |
This issue seems to be caused by a bug (dperini/nwsapi#115) in
update: the bug was still not fixed in |
@testing-library/jest-dom
version: 6.4.2node
version: 20.11.1vitest
version: 1.4.0npm
version: 10.5.0Relevant code or config:
What you did:
The above code should render a button with
background-color: #5FA00C
and it absolutely does. In a real browser I can see that it has the correct colour.What happened:
In the unittest, it errors out, telling me that its background colour is
rgb(62, 136, 0)
instead. This is incorrect. This colour happens to be the hover color. I am not simulating a hover anywhere. So why is it testing for that?Reproduction:
Forked Codesandbox
Although it no longer shows the tests tab, so I have no clue if this actually reproduces the problem. It appears codesandbox made a whoopsie. Sorry, nothing I can do about it.
Problem description:
I seem to be facing the opposite of issue 59 where it ignores hover styles. It always tests for hover styles now, no matter what (seemingly).
Suggested solution:
Don't do a hover on element to test
toHaveStyle
for, or something. Just ignore the hover styles.The text was updated successfully, but these errors were encountered: