title: Jest/Enzyme test React component with async/await method in try/catch
body: <p>I've been struggling trying to test this method with Jest for ages, searching online doesn't seem to help. I'm thinking I need to refactor this method but I'm not sure how to do it in such a way that is testable.</p>
  
  <pre class="lang-js prettyprint-override"><code>class EmailPage extends Component {
    ...
    async onSubmit(values, applicaitonId) {
      try {
        this.setState({ loading: true });
        const response = await sendEmail(this.formatEmailValues(values), applicaitonId);
        console.log(response)
        this.setState({ loading: false });
        if (response.status !== 'error') {
          this.props.history.push('/dashboard');
        } else {
          alert(
            `Something was wrong with your email. Error: ${response.message}`
          );
        }
      } catch (error) {
        console.error('Error while sending email!');
        console.error(error);
        this.setState({ loading: false });
      }
    }
    ...
  }
  </code></pre>
  
  <p>Any ideas?</p>