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

Notification Engine using Kafka & Apache storm

Updated May 15, 2019 09:05 AM

Help me understand the use of Avro in Kafka

Updated June 26, 2018 23:05 PM