Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

msb-test-utils

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

msb-test-utils

Testing utility modules for MSB

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

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.

FAQs

Package last updated on 24 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts