title: Catching thrown errors with SinonJS
body: <p>I've got a method that may throw an Error, but I'm having trouble writing a SinonJS/Mocha/Should unit test case for this condition.</p>
  
  <p>Sample function under test:</p>
  
  <pre><code>function testError(value) {
    if (!value) {
      throw new Error('No value');
      return false;
    }
  };
  </code></pre>
  
  <p>Sample test:</p>
  
  <pre><code>describe('#testError', function() {
    it('throws an error', function() {
      var spy = sinon.spy(testError);
      testError(false);
      spy.threw().should.be.true();
    });
  });
  </code></pre>
  
  <p>This outputs:</p>
  
  <pre><code>  #testError
      1) throws an error
  
  
    0 passing (11ms)
    1 failing
  
    1) #testError throws an error:
       Error: No value
        at testError (tests/unit/js/test-error.js:6:14)
        at Context.&lt;anonymous&gt; (tests/unit/js/test-error.js:14:6)
  </code></pre>
  
  <p>I was expecting Sinon to catch the Error and allow me to spy on the throw, but it seems to fail the test instead. Any ideas?</p>
  
  <p>I referred to <a href="https://stackoverflow.com/questions/18752369/dont-sinon-js-spys-catch-errors">Don&#39;t sinon.js spys catch errors?</a> but the only solution there is to use <code>expect</code>. I'd prefer to keep with a single assertion library if possible.</p>