title: Jest error '' TypeError: Cannot read property 'preventDefault' of undefined "
body: <p>I have a function as bellow and when i going to test the function i got the above error.</p>
  
  <p><strong>function</strong></p>
  
  <pre><code>toggleRecovery = e =&gt; {
      e.preventDefault()
      this.setState(
        {
          recovery: !this.state.recovery
        },
        () =&gt; {
          this.props.reset()
        }
      )
    }
  </code></pre>
  
  <p><strong>test</strong></p>
  
  <pre><code>test('if the recovery state is true should set the state to the false', () =&gt; {
        wrapper.setState({ recovery: true })
        //Check if the state is true initially
        expect(wrapper.state().recovery).toBeTruthy()
        //Calling the toggleRecovery()
        wrapper.instance().toggleRecovery()
        expect(wrapper.state().recovery).toBeFalsy()
        expect(props.reset).toHaveBeenCalled()
      })
  </code></pre>
  
  <p><strong>error</strong></p>
  
  <pre><code>TypeError: Cannot read property 'preventDefault' of undefined
  </code></pre>
  
  <p>How can i overcome this error  and what is cause the above error </p>