baseElement property Null safety

Node baseElement

The containing DOM node where your ReactElement is rendered in the container.

If you don't specify the baseElement in the options of render, it will default to document.body.

This is useful when the component you want to test renders something outside the container div, e.g. when you want to snapshot test your portal component which renders its HTML directly in the body.

See: testing-library.com/docs/react-testing-library/api/#baseelement-1

Implementation

Node get baseElement => _jsRenderResult.baseElement;