Skip to content

assert.throws works incorrectly for functions that throw undefined #18027

Closed
@not-an-aardvark

Description

@not-an-aardvark
  • Version: 9.3.0
  • Platform: macOS
  • Subsystem: assert

assert.throws and assert.doesNotThrow seem to treat functions that throw undefined the same way as functions that do not throw a value.

'use strict';

const assert = require('assert');

function foo() {
  throw undefined;
}

assert.throws(foo);

Expected behavior: assertion succeeds

Actual behavior: assertion fails

Metadata

Metadata

Assignees

No one assigned

    Labels

    assertIssues and PRs related to the assert subsystem.confirmed-bugIssues with confirmed bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions