Skip to content

Unit testing <Composer> with nested <Fetch> components? #58

@istan

Description

@istan

Hi! Thanks for the great libraries! I'm running into some issues trying to write enzyme unit tests for a component that follows a pattern like this, where Fetch comes from react-request:

<Composer components=[FetchComponentA, FetchComponentB] />
  {([fetchA, fetchB]) => {
     if (fetchA.failed || fetchB.failed) {
         return <ErrorPage ... />;
     }
     if (fetchA.fetching || fetchB.fetching) {
         return <LoadingPage ... />;
     }
     return <HappyPage ... />;
  }}
</Composer>

Do you have any examples you can share of how to test this pattern? I seem to be having trouble getting at the underlying promise chain, so my tests complete before fetchA, fetchB, fetchC all resolve.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions