title: How to unit test a callback function was called on a React component using Cypress
body: <p>I am trying to use <a href="https://github.com/bahmutov/cypress-react-unit-test" rel="nofollow noreferrer">cypress-react-unit-test</a> to unit test my React components.</p>
  <p>In this instance I have a Button, that gets passed a callback function to execute on click. I have the code below but fails immediately at the line highlighted. The error message is <code>expected stub to have been called at least once, but it was never called</code>.</p>
  <pre class="lang-js prettyprint-override"><code>import React from 'react';
  import { mount } from 'cypress-react-unit-test';
  
  const Button = ({ onClick }) =&gt; (
    &lt;button onClick={onClick} data-test-ref=&quot;button&quot;&gt;
      Hello
    &lt;/button&gt;
  );
  
  describe('Button', () =&gt; {
    it('should call the onClick function', () =&gt; {
      const onClick = cy.stub();
  
      mount(&lt;Button onClick={onClick} /&gt;);
      cy.get(`[data-test-ref=button]`).click();
  
      // expect(onClick).to.be.called; // fails
    });
  });
  </code></pre>
  <p>What am I doing wrong? How do I test that the onClick prop was executed when the button is clicked.</p>
  <p>Thanks</p>