New issue
Advanced search Search tips

Issue 678723 link

Starred by 1 user

Issue metadata

Status: Verified
Owner: ----
Closed: Jan 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 672152



Sign in to add a comment

should().beRejected() should take an error arg to specify the error?

Project Member Reported by rtoy@chromium.org, Jan 5 2017

Issue description

If a promise is rejected with an error, should().beRejected() doesn't allow the test to specify the type of error.  Should it? This makes it match should().throw().

 
I think the semantic is slightly different. This makes sense:
[a] should(expression).throw(someError)

However, this is not really clear:
[b] should(expression).beRejected(someError)

Perhaps it would be better with:
[c] should(expression).beRejectedWith(someError)

Note that this method without an argument reads awkward as well. 

This might be a matter of preference, but [b] is the easiest thing to do as you stated.

Comment 2 by rtoy@chromium.org, Jan 5 2017

We don't have to add it.  Just that some tests were written handle the rejected promise and then also checked the reason why.

Option [c] is ok if we make the arg required.
Option [c] means we have to fix the existing beRejected() assertion. Is it what we want?

Comment 4 by rtoy@chromium.org, Jan 6 2017

Are you saying [c] would replace all existing current uses of beRejected()?  That wasn't my intent, but we could.  But then I would say beRejectedWith() would need to support no arg for the cases where we don't care. I'm ok with having both beRejected() and beRejectedWith(required).

There is still the option of not doing anything.
Status: Started (was: Available)
Status: Verified (was: Started)

Sign in to add a comment