title: Mock a custom event
body: <p>Part of a simple React component:</p>
  
  <pre><code>const doIt=()=&gt;{
      window.dispatchEvent(new CustomEvent('info', {detail: [1,2,3]}));
  };
  return (
      &lt;button onClick={doIt}&gt;Hello&lt;/button&gt;
  )
  </code></pre>
  
  <p>The above custom event is being listened by another component far away in the tree and invokes a callback. I want to write a test about "Hello" button without involving the listener component. How should I mock the event?</p>