Asserts that given asynchronous function does reject the returned promise.
The function to call.
The expected error type the function is expected to throw.
The expected error message the function is expected to throw. Can be a string or a regular expression.
Optional
reason: stringOptional reason added to exception message when assertion fails.
Promise which must be awaited in order to complete assertion.
AssertionError when function throws exception not matching the given one (or does not throw anything when no error specified).
Asserts that given synchronous function does reject the returned promise.
The function to call.
The expected error type the function is expected to throw.
The expected error message the function is expected to throw. Can be a string or a regular expression.
Optional
reason: stringOptional reason added to exception message when assertion fails.
AssertionError when function throws exception not matching the given one (or does not throw anything when no error specified).
Asserts that given function (synchronous or asynchronous) does throw an exception with the given type and message. When function is asynchronous then
assertThrowWithMessage
returns a Promise which must be awaited in order to complete the assertion.Param: fn
function to test
Param: type
The expected error type the function is expected to throw.
Param: message
The expected error message the function is expected to throw. Can be a string or a regular expression.
Param: reason
Optional reason added to exception message when assertion fails.
Examples: