vendredi 18 janvier 2019

call child component function with enzyme

I have a component which uses a redux store, in order to make tests I created a Root component to wrap my original component supplying the store like this:

<Root>
 <MyComponent />
</Root>

I need to test MyComponent.function(), but I'm not able to execute it.

I tried to get my child component like this:

x = wrapper.find(MyComponent);
x.instance().function();

Aucun commentaire:

Enregistrer un commentaire