title: Jest test passes but error not caught and logs to console
body: <p>Is there a way to test custom errors in a component in Jest without there being an Uncaught error thrown in the console?</p>
  
  <p>Here I have a simple button component:</p>
  
  <pre><code>import React from 'react';
  
  export default class Button extends React.Component {
      render() {
  
          if (!this.props.type) {
              throw new Error('Button requires a type prop');
          }
  
          return (
              &lt;button className={`btn btn-${this.props.type}`}&gt;Button&lt;/button&gt;
          );
      }
  }
  </code></pre>
  
  <p>When the component is used without providing the type property, I want my custom error to be thrown. I also have the following Jest test:</p>
  
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import Button from './button';
  
  it('throws an error if the type prop is not defined', () =&gt; {
      const buttonType = undefined;
      const container = document.createElement('div');
  
      expect(() =&gt; {
          ReactDOM.render(&lt;Button type={buttonType} /&gt;, container);
      }).toThrow('Button requires a type prop');
  });
  </code></pre>
  
  <p>The unit test passes, however the console produces an error similar to:</p>
  
  <pre><code>console.error node_modules/jsdom/lib/jsdom/virtual-console.js:29
  Error: Uncaught [Error: Button requires a type prop]
  
  The above error occurred in the &lt;Button&gt; component:
  in Button (at button.spec.js:20)
  
  Consider adding an error boundary to your tree to customize error handling behavior.
  Visit https://reactjs.org/docs/error-boundaries.html to learn more about error boundaries.
  </code></pre>
  
  <p>Usually in Jasmine, the .toThrow() matcher would automatically catch the error and there would be no logging.</p>
  
  <p>I have read about error boundaries, but these seem to be in the application level, not in the component level.</p>
  
  <p>Am I missing an approach that is better suited to test this?</p>
  
  <p>Edit: Using the following versions:</p>
  
  <ul>
  <li>react: 16.2.0</li>
  <li>react-dom: 16.2.0</li>
  <li>jest: 22.2.2</li>
  </ul>