-
Notifications
You must be signed in to change notification settings - Fork 413
Description
@testing-library/jest-domversion: 6.4.2nodeversion: 20.11.1vitestversion: 1.4.0npmversion: 10.5.0
Relevant code or config:
render(<Button kind="primary" />);
const button = screen.getByRole('button');
expect(button).toHaveStyles({ 'background-color': '#5FA00C' });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.