title: Jasmine: How to expect promise handler to not throw exception
body: <p>I have this function:</p>
  
  <pre><code>reload() {
      myService.queryData()
          .done(...)
          .always(() =&gt; throw "fake exception"); //just to simulate the failure
  }
  </code></pre>
  
  <p>I want my test reload function and make sure it does not throw exception nor the promise callback does.</p>
  
  <pre><code>describe("reload", function () {
      it("does not throw exception", function (done) {
  
          spyOn(myService, "queryData").and.callFake(() =&gt; {
              let deffered = $.deffered();
              setTimeOut(() =&gt; deffered.reject(), 0)
              return deffered.promise();
          });
  
          reload();
          setTimeout(() =&gt; {
             //this is evaluated after the exception has been thrown, but
             //how to check whether exception has been thrown
          }, 2);
      });
  });
  </code></pre>
  
  <p>EDIT: I might not be able to return a promise in some cases, where the return type of the function is already defined, e.g component's lifecycle event:</p>
  
  <pre><code>MyComponent extends React.Component {
      componentDidMount() {
          this.load(
              galleryService.nodes().then(galleryResult =&gt; this.setState({ nodes: galleryResult.nodes }))
          );
          this.load(
              galleryService.caches().then(cachesResult =&gt; this.setState({ caches: cachesResult.caches }))
          );
      }
  }
  
  var myComponent = React.createElement(MyComponent);
  TestUtils.renderIntoDocument(myComponent); //this triggers the componentDidMount event and I need to make sure it won't throw error.
  </code></pre>