Skip to content

assert.throws is broken #2989

@silkentrance

Description

@silkentrance

See https://github.com/nodejs/node/blob/master/lib/assert.js#L305

Here, you test for !shouldThrow and expectedException(...).

In case of assert.throws() shouldThrow is always true and the above test will always fail, causing the instanceof test to never fail.

I think that the correct statement would be

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    assertIssues and PRs related to the assert subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions