Axinom Mosaic Libraries
    Preparing search index...
    • Test function. Checks that an async function throws an error on execution. It returns the thrown error. Allows easier inspection of the thrown error.

      Type Parameters

      • TErrorType = any

      Parameters

      • promise: Promise<any>

      Returns Promise<TErrorType>

       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