-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Closed
Labels
assertIssues and PRs related to the assert subsystem.Issues and PRs related to the assert subsystem.confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.
Description
- Version: Built from source off of latest master, df62e69. (This API has not appeared in a release yet.)
- Platform: macOS
- Subsystem: assert
The following code prints assertion passed
:
const assert = require('assert');
function functionThatThrows() {
throw new Error();
}
assert.rejects(functionThatThrows).then(
() => console.log('assertion passed'),
() => console.log('assertion failed')
);
This is unexpected because I would expect assert.rejects
to check that the given function returns a Promise which eventually rejects. In this case, no Promise is returned at all, so there is nothing that "rejects".
From an ergonomics perspective, if I were writing a function which could return a rejected Promise, I would want to always return a Promise to indicate errors, rather than sometimes throwing synchronously. If my function did throw synchronously rather than rejecting, this would be incorrect behavior and I would expect assert.rejects
to report the error.
Metadata
Metadata
Assignees
Labels
assertIssues and PRs related to the assert subsystem.Issues and PRs related to the assert subsystem.confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.