return error on throw method to chain on error properties #224

Merged
merged 1 commit into from Jan 2, 2014

Projects

None yet

5 participants

@vbardales

Allow to create that type of assertions:

expect(fn).to.throw(BadArgumentError).that.have.property('code', 500);

by chaining on the error instance, not on the function that throw an error

@coveralls

Coverage Status

Coverage remained the same when pulling c32ae3e on vbardales:master into 0e560c6 on chaijs:master.

@coveralls

Coverage Status

Coverage remained the same when pulling 2bb0ff2 on vbardales:master into 0e560c6 on chaijs:master.

@vbardales

up ?

@vesln
Member
vesln commented Jan 2, 2014

Makes sense to me. @logicalparadox?

@logicalparadox
Member

👍

@vesln vesln merged commit f3ebb09 into chaijs:master Jan 2, 2014

1 check passed

default The Travis CI build passed
Details
@larshvile

This change broke the previous way of doing further tests on the error. And the documentation hasn't been updated.

* Please note that when a throw expectation is negated, it will check each
* parameter independently, starting with error constructor type. The appropriate way
* to check for the existence of a type of error but for a message that does not match
* is to use `and`.
*
*     expect(fn).to.throw(ReferenceError)
*        .and.not.throw(/good function/);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment