【发布时间】:2018-09-13 20:00:00
【问题描述】:
我遇到了 Enzyme 浅层渲染器的问题。我的 wrapper.root.node 即使对于简单的 div 元素也会返回 null。
const wrapper = shallow(
<div>asd</div>
);
这里是 ShallowWrapper 对象。节点元素为空,但未渲染属性包含正常渲染的对象。这是为什么 ?
ShallowWrapper {
"complexSelector": ComplexSelector {
"buildPredicate": [Function],
"childrenOfNode": [Function],
"findWhereUnwrapped": [Function],
},
"length": 1,
"node": null,
"nodes": Array [
null,
],
"options": Object {},
"renderer": ReactShallowRenderer {
"_instance": null,
"getRenderOutput": [Function],
"render": [Function],
},
"root": [Circular],
"unrendered": <div>
asd
</div>,
}
【问题讨论】:
标签: javascript reactjs jestjs enzyme