import { Request, Response, NextFunction } from 'express'; import { NgitLocals } from "../../src/types/NgitLocals"; interface IMockHttpContext { reqPath?:string headersSent?:boolean writableEnded?:boolean method?:string } export const mockHttpContext = ({reqPath="/", headersSent=false, writableEnded=false, method="GET"}:IMockHttpContext|undefined = {}) => { const req = { path:reqPath, method, url:`https://localhost${reqPath}`, params: {}, } as unknown as Request; const res = { end: jest.fn(), status: jest.fn(), setHeader: jest.fn(), locals: { stopPrometheusTimer: jest.fn(), } as unknown as NgitLocals, headersSent, writableEnded, } as unknown as Response; const next:NextFunction = jest.fn(); return({req,res,next}) }