I am having an issue trying to test a component made with styled-components.
so i have two components and i am trying to get the second component's background color to change if i hover on the first element.
My components:
const Container = styled.div``
const Label = styled.label`
${Container}:hover & {
background-color: red;
}
`
Whenever i try to test the label component with jest expect(label).toHaveStyle()
it always throws an error that said TypeError: Cannot read property 'parentElement' of null
. But when i commented the reference to container component within label the test passes. Can anybody help? Thank you sooo much.
I am using react-testing-library to render my components in my test files.