Function assertThrows
- assert
Throws (fn, msg?): unknown Parameters
- fn: (() => unknown)
The function to execute.
- (): unknown
Returns unknown
Optionalmsg: stringThe optional message to display if the assertion fails.
Returns unknown
The error that was thrown.
- fn: (() => unknown)
- assert
Throws <E>(fn, ErrorClass, msgIncludes?, msg?): E Executes a function, expecting it to throw. If it does not, then it throws. An error class and a string that should be included in the error message can also be asserted.
To assert that an asynchronous function rejects, use
assertRejects.Type Parameters
Parameters
- fn: (() => unknown)
The function to execute.
- (): unknown
Returns unknown
- ErrorClass: (new (...args: any[]) => E)
The error class to assert.
OptionalmsgIncludes: stringThe string that should be included in the error message.
Optionalmsg: stringThe optional message to display if the assertion fails.
Returns E
The error that was thrown.
- fn: (() => unknown)
Executes a function, expecting it to throw. If it does not, then it throws.
To assert that an asynchronous function rejects, use
assertRejects.