-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[breaking] Don't convert non-Error promise rejection reason #582
Conversation
By analyzing the blame information on this pull request, we identified @therealklanni, @sotojuan and @SamVerschueren to be potential reviewers |
I remember we had some back and forth with this decision, but atm I'd also like to merge this and strictly expect |
I suppose yielding a custom Error to the consumer with a recommendation to reject Promises with actual Errors would be somewhat of a middle ground, if we're in 'back and forth land' that is? A missing expectation AssertionError doesn't explicitly highlight that fact (imho), but I didn't take a good look at what the error stack yielded as it stands. A custom Error could just be extraneous information. |
We all seem to be in agreement in #468 so let's not restart this argument 😉 |
@@ -81,8 +81,6 @@ x.throws = function (fn, err, msg) { | |||
x.throws(function () { | |||
if (fnErr instanceof Error) { | |||
throw fnErr; | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the if-guard as well, simply throw fnError
. This makes it equivalent to t.throws(() => { throw 'foo' })
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very well! I'll go ahead and amend my commit if you don't mind, and save myself the trouble of having to squash later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. It's going to conflict with #576 though 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. I'll get on this once #576 is merged.
@sindresorhus this will be a breaking change. |
c6214aa
to
2f10448
Compare
True, although I really doubt (hope) nobody depends on this behavior. |
Thanks @kasperlewau :) |
Thank you(s)! |
Promises that are rejected with a non-Error are currently passing expectations as we're converting to an Error in
lib/assert
.This PR changes the behaviour of
t.throws
so that it no longer considers the following example a pass:If the rejection reason is a non-Error,
core-assert
catches this which results in an AssertionError.Whereas the following would pass with flying colors:
Docs for
t.throws
saw a minor addition;Fixes #468