vendredi 19 juillet 2019

JavaScript - getting "res.json is not a function" error when testing with Mocha

I have the following function that i'm testing:

module.exports = {

    post: function myFunc(req, res) {
        some logic...
        ...
        ...
        res.json(ObjectToReturn);

}
}

And i'm trying to test in with Mocha like so:

  it("some test", function() {

      const response = myModule.post(
                           { reqPayLoad }, 
                           {}
                              );
      console.log(response)
  });

But i'm keep getting the error:

res.json is not a function

What am i doing wrong?

Aucun commentaire:

Enregistrer un commentaire