title: Jest Cannot read property 'createEvent' of null
body: <p>I was trying to mock rejected value and got this error. It's weird that this construction works in the case of &quot;success&quot; <code>addUser.mockImplementation(value =&gt; jest.fn().mockResolvedValue(value))</code>, but when I'm trying to do the same trick with rejecting, it doesn't work and says 'Cannot read property 'createEvent' of null'</p>
  <p>Here is my test case</p>
  <pre class="lang-js prettyprint-override"><code>it('receives invalid value and throws an error', async () =&gt; {
    addUser.mockImplementation(() =&gt;
      jest.fn().mockRejectedValue(new Error('Sample error'))
    )
  
    const enqueueSnackbar = jest.fn()
    useSnackbar.mockReturnValue({ enqueueSnackbar })
  
    const { emailInput, form, submitButton } = setup()
  
    await act(async () =&gt; {
      fillIn(emailInput, 'sample@mail.com')
    })
  
    expect(emailInput.value).toBe('sample@mail.com')
    expect(submitButton).toHaveProperty('disabled', false)
  
    await act(async () =&gt; {
      fireEvent.submit(form)
    })
  
    expect(enqueueSnackbar).toHaveBeenCalledTimes(1)
    expect(enqueueSnackbar).toHaveBeenCalledWith(`Sample error`, {
      variant: 'error'
  })})
  </code></pre>
  <p>Does anyone know how to make it work?</p>