I want to test my handler which is wrapped in middleware using middy
like this:
const main = async (event: APIGatewayProxyEvent): Promise<APIGatewayProxyResult> => {
// .... //
};
export const handle = middy(main)
.use(httpJsonBodyParser())
.use(customMiddleWare(ID))
.use(httpErrorHandler());
I want to ignore middy and all middleware and just want to test main
by passing in mock events and expecting the result but I have no idea how to do it without exporting main.
You can
export const main = ...
or have main in it's own file that's imported into the handler file.