Check That A Component Renders As Null
Consider a component that sometimes renders as null
.
How can we test the version of this component that renders as null
when hidden
is true
?
When react-testing-library renders a component, it wraps the whole thing in a surrounding <div>
. Knowing this, we can check if a component renders to null
by checking the contents of the wrapping <div>
container.
The component renders as null
, so the firstChild
of the RTL container
will be null
.
Last updated