Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enzyme shallow render is rendering children components

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?

like image 772
Morleee Avatar asked Nov 21 '16 16:11

Morleee


1 Answers

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.

like image 93
Andreas Köberle Avatar answered Sep 30 '22 08:09

Andreas Köberle