mardi 11 juin 2019

how to test rending inside a function in enzyme?

I have reactjs component where it's render function is like:

 render(){
 return (
  <ValleyContext.Consumer>
    {() => (<div>...</div>)}
  </ValleyContext.Consumer>
 )};

when I try to use the enzyme to test the internal of ValleyContext

const wrapper=shallow(<AMSRecent />, {context: {valley}});
console.log(wrapper.childAt(0));

and the result is:

[function]

I want to get the structure of

<div>...</div>

rather than just function. How should I get the internal structure of the rending?

Aucun commentaire:

Enregistrer un commentaire