酶浅渲染器 returns 空节点元素

Enzyme shallow renderer returns null node element

我对 Enzyme 浅层渲染器有疑问。即使对于简单的 div 元素,我的 wrapper.root.node 也返回 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>,
}

好的,jest引起的问题'react-dom' mock :

jest.mock('react-dom')

通过将单元测试移动到其他文件解决了问题。