'How to get the whole components tree in jest and testing-library/react-native?

I have a component that I am testing using jest and react native testing library that looks something like this :

<FallbackErrorBoundary>
  <Wrapper>
    <Component1>
      <Component2>

      </Component2>

    </Component1>
  </Wrapper>
 </FallbackErrorBoundary>

I want to get the whole rendered tree , I tried using

renderedComponent.container.children

But It only gets the direct children (FallbackErrorBoundary)

I tried using expect(renderedComponent).toMatchSnapshot() but It's not very helpful



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source