Skip to content

[8.x] assert.rejects fails with confusing error message #27185

Closed
@gcampax

Description

@gcampax
  • Version: latest 8.* series
  • Platform: not relevant
  • Subsystem: assert

The API of assert.rejects is different between the 10.* series and the 8.* series, because the backported 8.* version does not accept a Promise as first argument, it requires a Function that returns a rejected promise.
If you misuse the API, though, you get a confusing error message:

TypeError: errors.ERR_INVALID_ARG_TYPE is not a constructor
at waitForActual (assert.js:723:11)
at Function.rejects (assert.js:799:31)

This is because at

throw new errors.ERR_INVALID_ARG_TYPE('block', 'Function', block);
the throw line is incorrect.

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