0
votes

My component chain looks like below

enter image description here

My requirement here is to test Sidebar and MainBar components. And MainBar has routes in it.

Am using enzyme.Mount and I see it never renders the sideBar component

 const AppWrapper = enzyme.mount(
      <IntlProvider locale="en">
        <SideBar />
      </IntlProvider>
    );

expect(AppWrapper.find(Nav)).toBe(true);//It fails , it never finds the Nav.

Question : How to render SideBar which is part of route (:apps/teamsAppId) using enzyme.mount?

Note : Am using react-router-dom hooks

1
Do you have Nav when logging console.log(AppWrapper.debug())soumya sunny

1 Answers

0
votes

First of all, enzyme's find() returns a collection of dom nodes. So what you're actually doing is checking if a collection is true.

Try this instead: expect(AppWrapper.contains(Nav)).toBe(true);