title: How to expect an asynchronously thrown exception in Jasmine / Angular2 / Typescript?
body: <p>Given an Angular2/Typescript method that returns <strong>nothing</strong> and implements a .subscribe() handler which might throw, such as this:</p>
  
  <pre><code>onSubmit() { // returns nothing
    this.service.someCall(this.someData).subscribe(
      data =&gt; {
        return Promise.reject('This is an asynchronously thrown error.');
      },
      err =&gt; {},
    );
  }
  </code></pre>
  
  <p>(For the moment, let's assume that there's a good reason for this .subscribe() handler to (probably conditionally) reject without other testable side-effects, thus resulting only in an error message bubbling up to the top of the application.)</p>
  
  <p>How would one go about testing that this method resulted in a rejected Promise?</p>
  
  <p>I found some people with the same question, but no elegant answers:</p>
  
  <p><a href="https://stackoverflow.com/questions/31252888/how-to-deal-with-thrown-errors-in-async-code-with-jasmine#">How to deal with thrown errors in async code with Jasmine?</a></p>
  
  <p><a href="https://github.com/jasmine/jasmine/issues/529" rel="nofollow noreferrer">https://github.com/jasmine/jasmine/issues/529</a></p>
  
  <p><a href="https://gist.github.com/badsyntax/7769526" rel="nofollow noreferrer">https://gist.github.com/badsyntax/7769526</a></p>