How to write Jest test case for middleware in Node.js
export const validatePathParametr = (req: Request, res: Response, next: NextFunction): void => { const { id, name, } = req.params; try { validateId(id); validateName(name) } catch (error: any) { error.msg= ‘wrong parameter’; error.code= 500; getLogger().error({ req, error, }); return next(error); } return next(); }; function validateId(id){ if (!id || id === null) { throw new […]
What is the (smallest) setup to allow import to be used by Jest?
I’m having trouble running a module test in Node. I don’t have an existing project, and I can’t find one that has tests using import
statements.