Enzyme shallow render is rendering children components

我的梦境 提交于 2020-01-03 11:00:10

问题


I'm trying to shallow render a component to perform some basic unit tests.

The component I am doing this on has two child components which are rendered several times each depending on the parents props.

When querying the shallow rendered component, the child elements are being rendered -fully- also, meaning that the children's HTML elements are also accessible.

I am using Karma, Browserify, Jasmine and Enzyme, and can post the configs for each if needed. Has anybody seen similar behaviour before?


回答1:


This is the correct behaviour. The different to the other render methods from enzyme is, that it does not call any lifecycle methods and that it does not convert to real html, but it will render all its childs and childs of the childs and so on.



来源:https://stackoverflow.com/questions/40725254/enzyme-shallow-render-is-rendering-children-components

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!