【发布时间】:2018-09-17 17:57:44
【问题描述】:
我添加了一个组件,它使用函数作为子组件。我对这个停止工作的组件进行了浅酶测试。
如何对一个使用函数的组件进行浅层测试?
组件
return (
<I18n>
{({ i18n }) => (
<div />
)}
</I18n>
)
我尝试过的测试
import { shallow } from 'enzyme';
wrapper = shallow(<Component />)
.find('I18n')
.children();
console.log(wrapper.debug()); //outputs: [function]
wrapper = shallow(<Component />)
.find('I18n')
.children()();
// TypeError: (0 , _enzyme.shallow)(...).find(...).children(...) is not a function
【问题讨论】: