assert.throws(block[, error][, message])
Expects the function block to throw an error.
If specified, error can be a constructor, RegExp, or validation function.
If specified, message will be the message provided by the AssertionError if the block fails to throw.
Validate instanceof using constructor:
assert.throws(
() => {
throw new Error('Wrong value');
},
Error
);
Validate error message using RegExp:
assert.throws(
() => {
throw new Error('Wrong value');
},
/val