Mock implementation of ExoCom in JavaScript
a mock implementation of ExoCom-Dev for sending and receiving messages to your ExoServices in test
Installation
$ npm i --save-dev exocom-mock
Usage
-
create an instance
ExoComMock = require'exocom-mock'exocom = -
register a service to send messages to
exocomregisterService name: 'users'port: 4001 -
send a message to the service
exocomsendMessage service: 'users'name: 'users.create'message-id: '123'payload: name: 'Jean-Luc Picard' -
verifying messages sent out by the service under test
# ... make your service sent out a request here via exocom.sendMessage...# wait for the message to arriveexocomwaitUntilReceive =># verify the received messageexpectexocomreceivedMessagestoeqlname: 'users.created'payload:name: 'Jean-Luc Picard' -
if you want to verify more received messages later, you can reset the register of received messages so far
exocomreset -
finally, close your instance when you are done, so that you can create a fresh one for your next test
exocomclose
Development
See our developer documentation