-
-
Notifications
You must be signed in to change notification settings - Fork 145
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
toHaveStyleRule fails with media and supports option parameters #245
Comments
It could be that this is an issue with |
👋 I think we're having a similar issue, but with snapshot testing. It appears to fail with any 2 nested queries. Ive made a gist of our example |
Following up on what @dr3 said, we are seeing this with any nested rules. For example an |
Same issue with const component = withRouter(withTheme(<ItemCard title="Some title" date="10.04.2019" data-testid="item-card" />));
const { container, getByTestId } = render(component);
expect(container).toMatchSnapshot();
expect(getByTestId('item-card')).toHaveStyle('border-left: 8px solid');
expect(getByTestId('item-card')).toHaveStyleRule('background', rgba('#fff',1), {
modifier: ':before',
}); No style rules found on passed Component using options:
{"modifier":":before"}
20 | expect(container).toMatchSnapshot();
21 | expect(getByTestId('item-card')).toHaveStyle('border-left: 8px solid');
> 22 | expect(getByTestId('item-card')).toHaveStyleRule('background', rgba('#fff', 1), {
| ^
23 | modifier: ':before',
24 | });
25 | }); Plus TS throw an error "styled-components": "5.0.0", |
@baybara-pavel — I’d love to see the code for your actual styled component, too, to confirm that it’s the same issue. Regarding your TS error, I’ve run into that before as well — does it go away if your |
@erikvorhes yep, of course: import { rgba } from 'polished';
export const ItemCard = styled.div`
display: block;
position: relative;
min-height: 140px;
box-shadow: 0px 0px 16px rgba(0, 0, 0, 0.05);
border-radius: 4px;
border-left: 8px solid;
padding: 24px 32px;
padding-left: 24px;
&:before {
position: absolute;
content: '';
top: 0;
left: -8px;
width: 8px;
height: 100%;
background: ${rgba('#fff', 1)};
border-radius: 4px;
}
`; I'm not sure about relation between |
The issue is re-produced with the following versions. "react": "^16.13.1" |
I had the same issue, found out I had 2 versions of styled-components in package with:
|
#354 has been updated to include a fix for both snapshots and the |
Given this component:
and this test:
The test fails with this message:
Tests pass if a component has either a media query or a feature query, but not when they are nested.
My project uses:
Is there a workaround for this scenario?
The text was updated successfully, but these errors were encountered: