title: How to test form submit with jest and enzyme in react?
body: <p>I am learning reactjs form with hooks, now I would like to test form on submit using jest and enzyme.</p>
  <p>here is my login component.</p>
  <pre><code>import React from 'react'
  
  function Login() {
      const [email, setEmail] = useState('');
      const [password, setPassword] = useState('');
  
      const handleSubmit = async (e) =&gt; {
          e.preventDefault();
          // ....api calLS
      }
      return (
          &lt;div&gt;
               &lt;form onSubmit={handleSubmit} className=&quot;login&quot;&gt;
      
              &lt;input type=&quot;email&quot; id=&quot;email-input&quot; name=&quot;email&quot; value={email} onChange={e =&gt; setEmail(e.target.value)} /&gt;
          
              &lt;input type=&quot;password&quot; id=&quot;password-input&quot; name=&quot;password&quot; value={password} onChange={e =&gt;setPassword(e.target.value)} /&gt;
              
              &lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;
               &lt;/form&gt; 
          &lt;/div&gt;
      )
  }
  
  export default Login
  </code></pre>
  <p>Here is the login.test.js file</p>
  <pre><code> describe('my sweet test', () =&gt; {
      it('clicks it', () =&gt; {
        
         const wrapper = shallow(&lt;Login /&gt;);
         const updatedEmailInput = simulateChangeOnInput(wrapper, 'input#email-input', 'blah@gmail.com')
         const updatedPasswordInput = simulateChangeOnInput(wrapper, 'input#password-input', 'death'); 
  
         expect(updatedEmailInput.props().value).toEqual('blah@gmail.com');
         expect(updatedPasswordInput.props().value).toEqual('death');
  
         const instance = wrapper.instance()
         const spy = jest.spyOn(instance, 'handleSubmit')
     
         instance.forceUpdate();    
     
         const submitBtn = app.find('#sign-in')
         submitBtn.simulate('click')
         expect(spy).toHaveBeenCalled()
  
      })
      
    })
  </code></pre>
  <p>Unfortunately when I run <code>npm test</code> I get the following error.
  <a href="https://i.stack.imgur.com/HRGbs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HRGbs.png" alt="enter image description here" /></a></p>
  <p>What do I need to do to solve this error or can someone provide a tutorial on how to test a form submit?</p>