我有一个带有formio.js的React项目 问题就像我发现很难测试在反应容器中作为子组件呈现的Formio页面。
例如:
<div>
<Form form={some component} />
</div>
其中div是父组件或容器,而form是在div内部呈现的子组件。 子组件是使用formio json格式构建的。
实际的问题在于子组件的测试。
测试代码:我正在使用玩笑和酵素
test('child renders correctly', ()=>{
let formwrapper= mount(<Form form={some component} />);
return formwrapper
.instance
.createPromise
.then(formio => {
const {formHtml} = formio.render();
Console.log(formHtml);
expect (formHtml.find(<div class='some class'>)).toBe.true;
})
})
错误正好在.find函数上:它显示formHtml.find不是函数。
console.log(formHtml)在表单内打印html。
我在做什么错, 对于Formio js的任何参考表格编写测试都将受到赞赏。
谢谢。