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

assert: doesNotThrow doesn't show message #6400

@pkorzeniewski

Description

@pkorzeniewski

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;
  }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions