title: How to test a method dispatching custom event
body: <p>I have a static method that creates a custom event and dispatches it:</p>
  
  <pre><code>    class MyComponent extends {
         static refreshComponent() {
           const event = new Event('refreshComponent');
           document.dispatchEvent(event);
         }
         render() {
            MyComponent.refreshComponent();
         }
      }
  </code></pre>
  
  <p>I am trying test as below:</p>
  
  <pre><code>describe('refreshComponent', () =&gt; {
      it('should dispatch an event', () =&gt; {
        const document = { dispatchEvent: jest.fn() };
        wrapper.refreshGoalsComponent();
        expect(document.dispatchEvent).toHaveBeenCalledWith('refreshComponent');
      });
    });
  </code></pre>
  
  <p>But the dispatchEvent is not called here, as there is no mock for 'new Event()'. Is there a way to mock it? Please help</p>