JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 25
  • Score
    100M100P100Q45767F
  • License BSD-3-Clause

Powerful mockserver client wrapper based on builders with expectation, request matcher and action builders in TypeScript notation

Package Exports

  • mockserver-client-builder

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mockserver-client-builder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

MockServer client wrapper

Package release

Powerful mockserver client wrapper based on builders with expectation, request matcher and action builders in TypeScript notation.

About

The package provides the ability to program the MockServer in design mode.

Configure expectations, scheduling requests and responses through a convenient builder system.

Detailed API documentation of MockServer can be found on the official website.

Basics

npm i mockserver-client-builder
import { client } from 'mockserver-client-builder';

// Config
const config = {
  host: 'mockserver-srv',
  port: 1080,
  tls: false,
};

// Simple plain response mock
client(config)
  .mockSimpleResponse('/simple-mock-request', { music: 'Rock' }, 418);

Running MockServer in the Docker

For running MockServer in Docker for local usage you can apply this docker-compose.yml.

For advanced manual configuration of MockServer in Docker see this article.

Usage examples

After installing this NPM-package and setup local MockServer you can try this examples.

To run some scenario use nodejs CLI for compiled js.

$ eslint . --ext .ts
...
$ tcs --build
...
nodejs ./lib/expectations/complex-expectation.js

Now your MockServer is ready to accept requests with expectation responses based on complex-expectation.js scenario.

Run tests

For example, the MockServer started on mockserver-srv, without https and on 1080 port.

SCHEMA=http HOST=mockserver-srv PORT=1080 npm run test