Skip to content

[Feature Request] Implement assert.rejects() and assert.doesNotReject() #272

Closed

Description

@nev21

Feature Request

Add async/Promise assertion functions to match Node.js assert API.

Missing Functions

  • assert.rejects(asyncFn, error?, message?) - Awaits the asyncFn promise or, if asyncFn is a function, calls the function and awaits the returned promise. It will then check that the promise is rejected.
  • assert.doesNotReject(asyncFn, error?, message?) - Awaits the asyncFn promise or, if asyncFn is a function, calls the function and awaits the returned promise. It will then check that the promise is not rejected.

Current Workarounds

// Instead of assert.rejects()
await assert.throws(async () => await asyncFn());

// Instead of assert.doesNotReject()
await assert.doesNotThrow(async () => await asyncFn());

Node.js Documentation

Related

See migration guide: Migrating from Node.js Assert

Activity

  1. changed the title [-][Feature] [Feature Request] Implement assert.rejects() and assert.doesNotReject()[/-] [+][Feature Request] Implement assert.rejects() and assert.doesNotReject()[/+] on Aug 20, 2026
  2. added this to the 0.2.0 milestone on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions