DEV Community

Dimitrios Desyllas
Dimitrios Desyllas

Posted on

How I can mock an incomming http request in jest using node.js http?

I am making a handler library named handle_http.js:

module.exports.redirectHttpToHttps = (db,req,res)=>{
      const sql = "SELECT * from redirect where use_in_http = 1 and exact_match = 1 and url_from = ? and exact_match=1 LIMIT 1"
     // redirection logic
}

And I made a http server where consumes the library:

const

Top comments (1)

Collapse
 
markmatute profile image
Mark Matute

why would you want to mock it?