试图从酶中复制dive()
示例,但继续获得TypeError: wrapper.find(...).dive is not a function
代码:
class Bar extends React.Component {
render() {
return (
<div>
<div className="in-bar" />
</div>
);
}
}
class Foo extends React.Component {
render() {
return (
<div>
<Bar />
</div>
);
}
it('renders correctly', () => {
const wrapper = shallow(<Foo />);
expect(wrapper.find('.in-bar').length).toBe(0);
expect(wrapper.find(Bar).length).toBe(1);
expect(wrapper.find(Bar).dive().find('.in-bar').length).toBe(1);
});
答案 0 :(得分:0)
.dive()
已添加到酶v2.5.0中:
https://github.com/airbnb/enzyme/blob/master/CHANGELOG.md#250-october-17-2016