mercredi 20 mars 2019

JavaScript - Test On Communication With More Than One Entity

My micro-service A has this behavior: when it receives a message from service C it returns 200, does some calculations, and sends a new http request to service B.

I want to test A by mocking the request from C, and mock B to listen the request from A. The problem here is that simple asyncronous approach is not enough here, since the relevant output from A is sent to another entity (i.e. not as response to C).

I thought to do that by sending the request from C and setting timeout to check if something has arrived to B meantime, but it's not very elegant. Is there any way do that via test framework? (Prefer Mocha)

Aucun commentaire:

Enregistrer un commentaire