Closed
Description
react
version: 18@testing-library/react
version: 14@testing-library/jest-dom
version: 5.16.5
Relevant code or config:
import React from 'react';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
describe('a href testing', () => {
it('loads the default link', async () => {
render(
<>
<style dangerouslySetInnerHTML={{__html:`
.test{
background: green
}
.test:active {
background: red
}`}} />
<a href="#" data-testid="test" className="test">
test
</a>
</>
);
expect(screen.getByTestId('test')).toHaveStyle('background: green')
});
})
What you did:
Hey All, sorry if this is the wrong space but I recently just updated the version of our testing frameworks and every element that has an active state is failing as it seems to already apply the active styling. For an example the code above when tested complains that the background is actually red when I think it should be green by default?
Problem description:
My tests to check the default styling of a button are breaking because the tests now treat everything as an active state which has different styling
Suggested solution:
I don't have a suggested solution but the interim I can come up with is use an act() and just focus a different button to test the normal styling of a button.