title: How can I mock caatchAsync(error handler) with jest
body: <p>Im trying to unit test some middleware.</p>
  <pre class="lang-ss prettyprint-override"><code>export const someMiddleware = catchAsync(async (req: Request, res: Response, next: NextFunction) =&gt; {
  //...
  }
  </code></pre>
  <p>But  it always returns <code>undefined</code> because of <code>catchAsync</code></p>
  <pre class="lang-js prettyprint-override"><code>export const catchAsync = (fn: any) =&gt; {
    return function (req: Request, res: Response, next: NextFunction) {
      fn(req, res, next).catch(next);
    };
  };
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>
  describe('some middleware test', () =&gt; {
    let mockRequest: Partial&lt;Request&gt;;
    let mockResponse: Partial&lt;Response&gt;;
    let nextFunction: NextFunction = jest.fn();
  
    beforeEach(() =&gt; {
      mockRequest = {};
      mockResponse = {
        json: jest.fn(),
      };
    });
  
    test('this some throw error', async () =&gt; {
      const result = await someMiddleware(mockRequest as Request, mockResponse as Response, nextFunction);
      expect(result).toEqual('...');
    });
  });
  </code></pre>
  <p>So, what I'm missing or a keyword to resolve <code>catchAsync</code>?</p>