import type { MethodKeysOf } from '@kbn/utility-types' ; import { RequestHandlerContext , KibanaRequest , KibanaResponseFactory } from 'kibana/server' ; import { identity } from 'lodash' ; import { httpServerMock } from '../../../../../src/core/server/mocks' ; export function mockHandlerArguments ( { } , req , res ? ) { return [ { } as unknown as RequestHandlerContext , req as KibanaRequest < unknown , unknown , unknown > , mockResponseFactory ( res ) , ] ; } export const mockResponseFactory = ( resToMock = [ ] ) => { const factory = httpServerMock . createResponseFactory ( ) ; resToMock . forEach ( ( key ) => { if ( key in factory ) { Object . defineProperty ( factory , key , { value : jest . fn ( identity ) , } ) ; } } ) ; return factory as unknown as KibanaResponseFactory ; } ;