title: How can I make Jest test for a thrown error silently
body: <p>I’m writing a test to assert that a component throws an error if provided one prop but not another.</p>
  
  <p>The test itself passes, but the console still complains about an uncaught error and prints the entire stack trace. Is there a way I can get Jest to stop printing this information, as it pollutes the test runner and makes it look like something has failed.</p>
  
  <p>For reference, this is my test:</p>
  
  <pre><code>it("throws an error if showCancel is set to true, but no onCancel method is provided", () =&gt; {
      // Assert that an error is thrown
      expect(() =&gt; mount(&lt;DropTarget showCancel={ true }/&gt;)).toThrowError("If `showCancel` is true, you must provide an `onCancel` method");
  });
  </code></pre>
  
  <p>The error itself is thrown here:</p>
  
  <pre><code>if(props.showCancel &amp;&amp; !props.onCancel) {
      throw new Error("If `showCancel` is true, you must provide an `onCancel` method");
  }
  </code></pre>