title: How to simulate click event with mock function in enzyme and Jest?
body: <p>I have foo component I want to simulate button click with a mock function</p>
  
  <pre><code> export default class Foo extends Component {
          btnClick() {
              console.log("hello...");
          }
          render() {
              return (
                  &lt;div&gt;
                      &lt;h2&gt;Hello&lt;/h2&gt;
                      &lt;button onClick={this.btnClick.bind(this)} id="btn"&gt;Click&lt;/button&gt;
                  &lt;/div&gt;
              );
          }
      }
  </code></pre>
  
  <p>My test code looks like following </p>
  
  <pre><code> it("must call the mock method with button click", () =&gt; {
  
          const wrapper = mount(&lt;Foo /&gt;);
          wrapper.instance().btnClick = jest.fn(() =&gt; {
              return 8;
          });
  
          wrapper.update();
  
          const btn = wrapper.find("#btn");
          btn.simulate("click");
  
          expect(wrapper.instance().btnClick).toHaveBeenCalled();
      })
  </code></pre>
  
  <p>simulation of click event calls the components real method instead of calling the mock method.</p>
  
  <p>I know it can be done by passing mock function as props to the <code>&lt;Foo/&gt;</code> component. </p>
  
  <p>I want to know is there any other way to simulate click(<strong>i.e private to the component</strong>) with mock method.</p>