Neighbourhood Party Manager

mock-office

0.14.4 • Public • Published

Mock Office

travis build status npm version Coverage Status

Tool for running mock servers locally to faciliate frontend development.

  • Create and run multiple HTTP and Web Socket servers instantly.
  • Cover complex scenarios, including delays, backend error responses, custom headers etc.
  • Run it locally or on shared resources, CI.

Table of contents:

  1. Installation
  2. Usage
  3. Adding expectations
  4. Test

Instalation

Install from npm:

$ npm run install mock-office -g

Usage

$ mock-office [server type] [parameters]

CLI parameters:

server type - http or ws

--src, -s - path to file with mocks

--port, -p - port to listen (default 3000)

Adding expectations

Admin REST server starts along with mock server on port (server port + 1).

POST /expectation

Http server

{
    "request": {
        // matchers
    },
    "response": {
        // params
    }
}

Request matchers:

  • headers - Object - key-value pairs of HTTP headers

  • method - String - HTTP method

  • path - String - url path

Response parameters:

  • headers - Object - key-value pairs of HTTP headers

  • status - Number - HTTP status code

  • body - String - stringified body content

  • delay - Number - delay time in ms

Web socket server

{
    "connection": {
        // matchers
    },
    // or
    "incomingMessage": {
        // matchers
    },
    "messages": [
        {
            // params
        }, // ...
    ]
}

connection matchers

// no matchers at the moment

incomingMessage matchers:

  • body - String - message body

message parameters:

  • delay - Number - delay time in ms

  • interval - Number - interval time in ms

  • body - String - plain text body content

Test

To run tests:

$ npm test

Keywords

install

npm i mock-office

Downloadsweekly downloads

18

version

0.14.4

license

CC0-1.0

repository

Gitbitbucket

last publish

collaborators

  • avatar
Report a vulnerability