GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — assert.throws works incorrectly for functions that throw `undefined` · Issue #18027 · nodejs/node

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

New issue
Copy link
New issue
Copy link
Closed
Closed
assert.throws works incorrectly for functions that throw undefined#18027
Copy link
Labels
assertIssues and PRs related to the assert subsystem.confirmed-bugIssues and PRs for confirmed bugs.

Description

@not-an-aardvark
not-an-aardvark
opened on Jan 7, 2018
Issue body actions
  • 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

Activity

  1. not-an-aardvark
    added
    assertIssues and PRs related to the assert subsystem.
    confirmed-bugIssues and PRs for confirmed bugs.
    on Jan 7, 2018
  2. bnoordhuis
    added a commit that references this issue on Jan 7, 2018

    lib: handle `throw undefined` in assert.throws()

    54f3cff
  3. bnoordhuis commented on Jan 7, 2018

    @bnoordhuis
    bnoordhuis
    on Jan 7, 2018
    Member
    More actions

    #18029

  4. BridgeAR commented on Jan 7, 2018

    @BridgeAR
    BridgeAR
    on Jan 7, 2018
    Member
    More actions

    As far as I see it, it was never really supported to do this. In Node.js < 8.3 all falsy values failed. Afterwards only undefined failed.

  5. jasnell
    closed this as completedin 71203f5on Jan 10, 2018
  6. BridgeAR
    added a commit that references this issue on Mar 8, 2018

    lib: handle `throw undefined` in assert.throws()

    49dc778
  7. MylesBorins
    added 2 commits that reference this issue on Mar 15, 2018

    lib: handle `throw undefined` in assert.throws()

    2f76179

    lib: handle `throw undefined` in assert.throws()

    b35eabb
  8. sjarmak
    added a commit that references this issue on Jul 27, 2026

    lib: handle `throw undefined` in assert.throws()

    71203f5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.