2.0.0 • Published 8 years ago

msb-test-utils v2.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

msb-test-utils Build Status

Testing utility modules for MSB implementers.

mockResponderFactory

var mockResponderFactory = require('msb-test-utils/mockResponderFactory');

mockResponderFactory.create(msb, options, channelManager)

Sets up a new responder using the provided options and optional channelManager and returns an API for setting up mock responses.

Example:

  msb.configure({ brokerAdapter: 'local' });

  mockResponderFactory.create({
    namespace: 'test:topic'
  });

mockResponder.respondWith(responseArr)

Adds response instructions for one request. Repeat for each expected request.

  • responseArr Array Instructions for responses to a request.
    • waitMs Optional Integer Milliseconds to wait before publishing this response.
    • type Optional String ('ack'|'payload') The type of response to provide (Default: 'payload')
    • timeoutMs Optional For ack instructions only - see responder.sendAck.
    • responsesRemaining Optional For ack instructions only - see responder.sendAck.
    • payload Optional For payload instructions only - see responder.send.

Example:

  mockResponder
  .respondWith([
    { type: 'ack', timeoutMs: 2000 },
    { waitMs: 1000, payload: { ... } }
  ]) // Responses to first request
  .respondWith([
    { payload: { ... } }
  ]) // Responses to second request

mockResponder.end()

Stops the responder from listening for requests and clears all timeouts, commonly put in an afterEach block.

2.0.0

8 years ago

1.0.0

8 years ago