在 Jest-emotion 的 tohaveStyleRule 中找不到背景 属性
Background property not found in Jest-emotion's tohaveStyleRule
我正在尝试根据传递的 prop active 测试默认和更改的背景,但是,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 | );
事实证明他们仍在建立支持并且现在有效
我正在尝试根据传递的 prop active 测试默认和更改的背景,但是,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 | );
事实证明他们仍在建立支持并且现在有效