Where to place the done() call in Jest unit tests on a middleware that logs the request body to the db?

Dimitrios Desyllas - Apr 15 '23 - - Dev Community

I have asked thsi question:

I am making my own custom middleware that logs the http body to the database

logger.js

const connect = require('connect')
module.exports = function(db_con){
  const app = connect();
  app.use((req,res,next)=>{
     const sql = `INSERT INTO requests VALUES (:method,:url) returning id`;
     const stmt  = db.prepare(initialInsert);

     const insert_result = initialInsertStmt.run({method:req.method,'url':req.url            });
     req.id = insert_result.lastInsertRowid;

I am in progress of making my own middleware that logs the http request body into DB. But I have trouble on testing it because I do not knwo where to place the jest's done function.

Any idea on that?

Happy Jesus Resurection (Καλή Ανάσταση for Greek Orthodox)

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player