vendredi 2 novembre 2018

good way to test Node.js code using stubs

I have written a function that calls two REST API and converts it into the needed format & this function is consumed by the third party UI tool.

The code structure looks like below

F1 - call REST 1 end point

F2 - call Rest 2 endpoint

F3 - get data from F1 and F2 and expose it as function

I have written test case for this use case using Sinon and proxyquire & ended up with three test case - one test case for each file.

using proxyquire I am defining external response call & stubbing it using sinon.

using this approach I am able to test individual files input-output but I am looking for a way where I should able to test it whole functionality end to end.

Aucun commentaire:

Enregistrer un commentaire