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