|
@ -37,11 +37,44 @@ Tests strict non-equality, as determined by the strict not equal operator ( `!== |
|
|
|
|
|
|
|
|
### assert.throws(block, [error], [message]) |
|
|
### assert.throws(block, [error], [message]) |
|
|
|
|
|
|
|
|
Expects `block` to throw an error. |
|
|
Expects `block` to throw an error. `error` can be constructor, regexp or |
|
|
|
|
|
validation function. |
|
|
|
|
|
|
|
|
|
|
|
Validate instanceof using constructor: |
|
|
|
|
|
|
|
|
|
|
|
assert.throws( |
|
|
|
|
|
function() { |
|
|
|
|
|
throw new Error("Wrong value"); |
|
|
|
|
|
}, |
|
|
|
|
|
Error |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
Validate error message using RegExp: |
|
|
|
|
|
|
|
|
|
|
|
assert.throws( |
|
|
|
|
|
function() { |
|
|
|
|
|
throw new Error("Wrong value"); |
|
|
|
|
|
}, |
|
|
|
|
|
/value/ |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
Custom error validation: |
|
|
|
|
|
|
|
|
|
|
|
assert.throws( |
|
|
|
|
|
function() { |
|
|
|
|
|
throw new Error("Wrong value"); |
|
|
|
|
|
}, |
|
|
|
|
|
function(err) { |
|
|
|
|
|
if ( !(err instanceof Error) || !/value/.test(err) ) { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
"unexpected error" |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
### assert.doesNotThrow(block, [error], [message]) |
|
|
### assert.doesNotThrow(block, [error], [message]) |
|
|
|
|
|
|
|
|
Expects `block` not to throw an error. |
|
|
Expects `block` not to throw an error, see assert.throws for details. |
|
|
|
|
|
|
|
|
### assert.ifError(value) |
|
|
### assert.ifError(value) |
|
|
|
|
|
|
|
|