Test function. Checks that an async function throws an error on execution. It returns the thrown error. Allows easier inspection of the thrown error.
const error = await rejectionOf<MosaicError>(handler.onMessage(body, message)); expect(error.message).toBe('Some error message'); expect(error.code).toBe('SOME_CODE'); Copy
const error = await rejectionOf<MosaicError>(handler.onMessage(body, message)); expect(error.message).toBe('Some error message'); expect(error.code).toBe('SOME_CODE');
For synchronous functions use expectFailure
expectFailure
Test function. Checks that an async function throws an error on execution. It returns the thrown error. Allows easier inspection of the thrown error.