使用Jest和Enzyme,我试图测试我的Logo组件接收正确的道具(id
,height
,width
,active
,disableTransparency
)。
我尝试过创建一个实例(wrapper.instance()
),但这会返回null。我也尝试过wrapper.getElement().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()
吗?这就是我在使用Enzyme时通常会获得组件的道具。