使用Jest和Enzyme,我正在尝试测试我的Logo组件是否接收正确的道具(id
,height
,width
,active
,disableTransparency
(。
我尝试创建一个实例(wrapper.instance()
(,但这返回 null。我也尝试过wrapper.getElement().props
,这将返回渲染组件的 props。
const Logo = ({id, height, width, active, disableTransparency}) => (
<Svg x='0px' y='0px' height={height} width={width} viewBox='0 0 1000 1000'>
{(active) && <Gradient id={id}/>}
{(disableTransparency) && <Underlay/>}
<Overlay id={id} active={active}/>
</Svg>
);
你试过wrapper.props()
吗? 这就是我在使用酶时通常如何获得组件的道具。