title: Test that React prop method has been called with Jest
body: <p>I have an Input component, which accepts a prop method and calls it when the user types something in. Code itself works as expected, but for some reasons, test fails. It thinks that prop method wasn't called. Why is it happening? For testing purposes, I use Jest and react-testing-library.</p>
  
  <p>And second question. In real application, my idea is to test parameters that were passed to that prop method. Is it considered to be an implementation testing (I know that I should test it)?</p>
  
  <blockquote>
    <p>Input.js</p>
  </blockquote>
  
  <pre><code>export default function Input({ onChange }) {
    return &lt;input onChange={onChange} /&gt;;
  }
  </code></pre>
  
  <blockquote>
    <p>Test</p>
  </blockquote>
  
  <pre><code>import React from "react";
  import { render, act, cleanup, fireEvent } from "react-testing-library";
  import Input from "./input";
  
  describe("Input tests", () =&gt; {
    afterEach(cleanup);
  
    it("Should call prop function", () =&gt; {
      const onChange = jest.fn();
      const { getByTestId } = render(&lt;Input onChange={onChange} /&gt;);
      const input = getByTestId("input");
  
      act(() =&gt; {
        fireEvent.change(input, { target: { value: "Q" } });
      });
  
      expect(onChange).toHaveBeenCalled();
    });
  });
  </code></pre>
  
  <p><a href="https://codesandbox.io/s/y229669nvx" rel="nofollow noreferrer">https://codesandbox.io/s/y229669nvx</a></p>