How can I test if my styled-component
has a specific CSS attribute-value pair?
Let's say my component is the following :
const myColor = '#111';
const Button = styled.button`
background-color: ${myColor};
`;
And the test checks that the 'background-color'
attribute has the value '#111'
.
The test runner is Jest and I use the testing utilities library Enzyme.
const Button = styled.button' && { background-color: ${myColor}; }';
toHaveStyleRule
doesn't work in this case for me – Sextillion