Function assertRejects
- assert
Rejects (fn, msg?): Promise<unknown> Parameters
- fn: (() => PromiseLike<unknown>)
The function to execute.
- (): PromiseLike<unknown>
Returns PromiseLike<unknown>
Optionalmsg: stringThe optional message to display if the assertion fails.
Returns Promise<unknown>
The promise which resolves to the thrown error.
- fn: (() => PromiseLike<unknown>)
- assert
Rejects <E>(fn, ErrorClass, msgIncludes?, msg?): Promise<E> Executes a function which returns a promise, expecting it to reject. 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 a synchronous function throws, use
assertThrows.Type Parameters
Parameters
- fn: (() => PromiseLike<unknown>)
The function to execute.
- (): PromiseLike<unknown>
Returns PromiseLike<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 Promise<E>
The promise which resolves to the thrown error.
- fn: (() => PromiseLike<unknown>)
Executes a function which returns a promise, expecting it to reject.
To assert that a synchronous function throws, use
assertThrows.