title: How to test refs in Jest and Enzyme
body: <p>I have a function which looks like this:</p>
  
  <p><code>handleSecondaryEmailDelete = () =&gt; {this.refs.contactEmailDialogBox.openModal();}</code></p>
  
  <p>Now, I am trying to test this function using Jest and Enzyme like:</p>
  
  <pre><code>`it('test if the handleSecondaryEmailDelete function is present',() =&gt; {
      let   wrapper = shallow(&lt;ContactDrawer /&gt;);         
      wrapper.instance().handleSecondaryEmailDelete();
    });`
  </code></pre>
  
  <p>So, when I run this test, I get an error saying:</p>
  
  <p><code>TypeError: Cannot read property 'openModal' of undefined</code> </p>
  
  <p>I know this error is because of the refs, I also tried searching for ways to test the refs in a react component, but I couldn't find any solution. Can anyone please tell me how to do the same?</p>