Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to test node.js http client with mocha?

I have a node.js module that HTTP POSTs a JSON request,

I want to test for correct url, headers, request body and that the request is actually executed.

I'm using Mocha for a testing framework. how do I test it ?

like image 484
Gal Ben-Haim Avatar asked Nov 25 '22 15:11

Gal Ben-Haim


1 Answers

You can use nock. you can intercept the http request and with certain properties

like image 137
Francisco Rojas Avatar answered Mar 17 '23 02:03

Francisco Rojas