Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

assert: doesNotThrow doesn't show message #6400

Closed
pkorzeniewski opened this issue Oct 23, 2013 · 1 comment
Closed

assert: doesNotThrow doesn't show message #6400

pkorzeniewski opened this issue Oct 23, 2013 · 1 comment

Comments

@pkorzeniewski
Copy link

In the documentation, assert.doesNotThrow takes two arguments: (block, [message]), but calling

assert.doesNotThrow(function() {
    // some code throwing an error
}, "Error occured");

won't display the "Error occured" message, but the thrown error instead. I've inspected the assert.js file, and the problem is probably caused by line 304:

if (!shouldThrow && expectedException(actual, expected)) {

expectedException will always return false, because expected is always set to null

 if (util.isString(expected)) {
    message = expected;
    expected = null;
  }
diversario added a commit to diversario/node-old that referenced this issue Nov 6, 2013
Addresses nodejs#6400.
Special handling to detect when user has supplied a custom message.
Added a test for user message.
@jasnell
Copy link
Member

jasnell commented Aug 27, 2015

There is a new PR opened in nodejs/node tracking this issue. Closing here.

@jasnell jasnell closed this as completed Aug 27, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants