You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
This updates `assert.rejects()` to disallow any errors that are thrown
synchronously from the given function. Previously, throwing an error
would cause the same behavior as returning a rejected Promise.
Fixes: nodejs#19646
This updates `assert.rejects()` to disallow any errors that are thrown
synchronously from the given function. Previously, throwing an error
would cause the same behavior as returning a rejected Promise.
Fixes: nodejs#19646
PR-URL: nodejs#19650
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This updates `assert.rejects()` to disallow any errors that are thrown
synchronously from the given function. Previously, throwing an error
would cause the same behavior as returning a rejected Promise.
Fixes: nodejs#19646
PR-URL: nodejs#19650
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This updates `assert.rejects()` to disallow any errors that are thrown
synchronously from the given function. Previously, throwing an error
would cause the same behavior as returning a rejected Promise.
Fixes: #19646
Backport-PR-URL: #24019
PR-URL: #19650
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
The following code prints
assertion passed
: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.The text was updated successfully, but these errors were encountered: