【发布时间】:2020-05-17 04:19:33
【问题描述】:
我正在尝试根据传递的 prop 活动测试默认和更改的背景,但是,jest-emotion 声称无法在样式组件上找到属性背景。我试过让它更具体(背景颜色和背景图像),但都不起作用。
样式化组件:
const StyledButtonToolbar = styledWithTheme(ButtonToolbar)<StylingProps>`
display: -webkit-box;
display: -ms-flexbox;
display: flex;
position: absolute;
right: 26px;
padding-left: 30px;
background: linear-gradient(to right, transparent, ${(props: any) =>
props.active === "true" ? props.theme.colors.highlight : "white"});
`;
期望调用的默认状态:
expect(wrapper.find(ButtonToolbar)).toHaveStyleRule(
"background",
"linear-gradient(to right, transparent, white)",
);
错误:
Property not found: background
38 | </Provider>,
39 | );
> 40 | expect(wrapper.find(ButtonToolbar)).toHaveStyleRule(
| ^
41 | "background-image",
42 | `linear-gradient(to right, transparent, ${props => props.theme.colors.highlight})`,
43 | );
【问题讨论】:
标签: reactjs jestjs enzyme emotion