0
我有一个组件调用Foo
和render
功能是这样的:酶 - 如何检测组件是否使用shallow()方法呈现?
render() {
if (!this.props.something) {
return null;
}
return (
<div>
<Bar />
<Baz />
</div>
);
}
我想测试Foo
部件,看是否div
呈现:
test('is div rendered',() => {
const component = shallow(
<Foo something={false} />
);
expect(component.find('div').at(0).exists()).toBeFalsy();
});
但测试结果在true
。我该如何测试,使用shallow
渲染方法是否存在div
?
嘿,我的回答是否解决了您的问题? @JoeTidee –
我还没有实现它。 – JoeTidee