title: Test the function inside click handler - Jest, React testing Library
body: <p>I have a button click handler in which I call another function. I need to test the function call inside of the handler:</p>
  <p><strong>SomeComponent</strong></p>
  <pre><code>...
  const handler = () =&gt; {
    someFunction();
  }
  ...
  &lt;button data-testId=&quot;button&quot; onClick={handler}&gt;Click Me&lt;/button&gt;
  </code></pre>
  <p><strong>test</strong></p>
  <pre><code>describe('Button click', () =&gt; {
    it('button click', async () =&gt; {
      render(&lt;SomeComponent /&gt;);
  
      const button = await screen.findByTestId('button');
      fireEvent.click(button);
      // some silly test case just for example
      expect(button).toBeInTheDocument();
    });
  });
  </code></pre>
  <p>While doing this, it covers the handler but not the inner function itself:</p>
  <pre><code>const handler = () =&gt; { &lt;&lt;&lt;&lt;&lt;&lt;&lt; covered
    someFunction();       &lt;&lt;&lt;&lt;&lt;&lt;&lt; UNCOVERED
  }.                      &lt;&lt;&lt;&lt;&lt;&lt;&lt; covered
  </code></pre>
  <p>The main question here is how can I test the inner function call? If I need to mock it, how should I do it, because the mocked function will not test the actual one?</p>
  <p><strong>UPDATE</strong></p>
  <p>Also, my someFunction doesn't change anything in the scope of this component, so I can't catch it by comparing the inner state or document change.</p>
  <p>SomeFunction is coming from another file and I tested it separately.</p>