How to unit test a service which output is an event with data?

by Cap Baracudas   Last Updated October 09, 2019 15:05 PM

Technologies : NodeJs, Kafka, Mocha

The issue : I have a nodeJS service which given a String returns events with a many data.

How can I test this using Mocha ?

In a simple scenario the service returns one event with some data attached. In a more complex scenario the service publishes multiple events.

Is there a way I can test the services output at unit test level?

Possible solutions : A solution I can think of is to create a consumer inside the mocha test. Is there another practice/method I can follow ? Should I test this at a different level aka integration level ?



Related Questions


Updated January 29, 2018 21:05 PM

Updated June 02, 2019 10:05 AM

Updated May 15, 2019 09:05 AM

Updated June 26, 2018 23:05 PM

Updated June 17, 2017 09:05 AM