title: react formik, test if submit function called on click - jest,enzyme
body: <p>I am testing a react component which contains a form(using formik) and I need to test if on submit button clicked, whether submit function is called or not.</p>
  
  <p>at the moment, the test is failing. 
  now, the form has required fields schema too using yup 
  so, I was wondering whether I need to fill up all the fields before testing it.
  because at the moment, it doesnt submit until the form has errors i.e. if the required fieldss are empty. so does that obstruct the testing of the button click and the function being called or not?</p>
  
  <pre><code>describe('submitform', () =&gt; {
    let wrapper = '';
    const handleSubmit = jest.fn();
    beforeEach(() =&gt; {
          wrapper = mount(&lt;ExampleButton  &gt;
                            &lt;span className="visible-sm"&gt;Next&lt;/span&gt;
                            &lt;span className="visible-xs font-entity"&gt;
                              &amp;rsaquo;
                            &lt;/span&gt;
                            &lt;/ExampleButton&gt;
          );
        });
    afterEach(() =&gt; {
          wrapper.unmount();
        });
    it('call function on click',async ()=&gt; {    
  
      // let btn = wrapper.find('#btnEx').find('button').find('#btnEx');
      let btn = wrapper.find('button').simulate('click');
      console.log('wrapper : ',btn.debug());
      // btn.props().onClick();
      expect(handleSubmit).toHaveBeenCalled();
    });
  })
  </code></pre>
  
  <p>how do I fill up the fields then, before testing? or is it even required for me to fill up the fields before testing on click?</p>