mercredi 24 octobre 2018

React test to see if component returns another component?

I have a Parent component which returns a Child component. The Child component returns null but reads the URL and fires off a Redux action:

    const Parent = () => {
      return (
        <>
            <h1>Title</h1>
            <Child />
        </>
      );
    };


    const Child = () => {
      componentDidMount(){
        // Do Redux stuff 
      }

      return null;
    };

I'm trying to write tests for Parent. How can I check that Child was returned? All the examples Ive seen test for HTML but this won't work for my use case.

Aucun commentaire:

Enregistrer un commentaire