title: Sinon-chai calledWith(new Error()) and with exact message
body: <p>I need to test this function :</p>
  <pre class="lang-js prettyprint-override"><code>   //user.js
      function getUser(req, res, next){
      helper.get_user(param1, param2, (err, file) =&gt; {
          if (err) return next(err);
      }
  
  </code></pre>
  <p>This is my test function :</p>
  <pre class="lang-js prettyprint-override"><code>it (&quot;failed - helper.get_user throws error&quot;, sinon.test(function () {
      var req, res;
      var get_user = this.stub(helper, &quot;get_user&quot;)
      get_user.yields(new Error(&quot;message&quot;));
      var next = sinon.spy(next);
      user.get_user(req, res, next);
      expect(next).to.have.been.calledWith(new Error(&quot;other message&quot;));
  }))
  </code></pre>
  <p>For my assertion I'm using <a href="https://www.chaijs.com/plugins/sinon-chai/" rel="nofollow noreferrer">sinon-chai</a> syntax.</p>
  <p>This test is passing even though I would expect it to fail, because my code doesn't throw a message with the error.</p>
  <p>How can I test that an error is thrown with correct message?</p>