title: How to simulate an event on a unit test with Jest, Enzyme for React-Native
body: <p>I'm trying to figure out how to test an "onPress" event with Jest in a React-Native app so I can make sure the right function is called.</p>
  
  <p>I went through the documentation and Google but couldn't find a solution for it in React-Native. </p>
  
  <p>This is what I found that is supposed to work for React-Native with <code>enzyme</code>:</p>
  
  <pre><code>const mockFunc = jest.fn();
  const component = mount(&lt;MyComponent onPress={mockFunc} /&gt;);
  component.simulate('press');
  expect(mockFunc).toHaveBeenCalled();
  </code></pre>
  
  <p>But this doesn't work. Seems like <code>mount</code> doesn't work and I get this output:</p>
  
  <blockquote>
    <p>ReferenceError: document is not defined</p>
  </blockquote>
  
  <p>I tried with <code>shallow</code> instead but the <code>TouchableOpacity</code> is not getting rendered when I look at the output of the function... and you've guessed it, it doesn't work either. Not sure what to do.</p>
  
  <p>Does anyone found a way to test events on React-Native?</p>
  
  <p>Thanks</p>