All Projects → mock-server → Mockserver Client Node

mock-server / Mockserver Client Node

Licence: apache-2.0
MockServer javascript client for browsers, Node.js or any grunt build

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Mockserver Client Node

Mockserver
MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and…
Stars: ✭ 3,479 (+6590.38%)
Mutual labels:  proxy, node-module, mock-server
Mitm Scripts
🔄 A collection of mitmproxy inline scripts
Stars: ✭ 109 (+109.62%)
Mutual labels:  proxy, mock-server
Mockttp
Powerful friendly HTTP mock server & proxy
Stars: ✭ 346 (+565.38%)
Mutual labels:  proxy, mock-server
Smocker
Smocker is a simple and efficient HTTP mock server and proxy.
Stars: ✭ 465 (+794.23%)
Mutual labels:  proxy, mock-server
mockserver-node
Node.js module and grunt plugin to start and stop MockServer and MockServer Proxy
Stars: ✭ 34 (-34.62%)
Mutual labels:  mock-server, node-module
Wiremockui
Wiremock UI - Tool for creating mock servers, proxies servers and proxies servers with the option to save the data traffic from an existing API or Site.
Stars: ✭ 38 (-26.92%)
Mutual labels:  proxy, mock-server
Mtprotoproxy
Async MTProto proxy for Telegram
Stars: ✭ 1,014 (+1850%)
Mutual labels:  proxy
Hexo Auto Category
Generate categories automatically for each post in Hexo
Stars: ✭ 49 (-5.77%)
Mutual labels:  node-module
2chproxy.pl
HTTP proxy for 2ch.net to convert the dat format.
Stars: ✭ 42 (-19.23%)
Mutual labels:  proxy
Pysocks
A SOCKS proxy client and wrapper for Python.
Stars: ✭ 1,005 (+1832.69%)
Mutual labels:  proxy
Megalodon
Mastodon, Pleroma and Misskey API client library for node.js and browser
Stars: ✭ 52 (+0%)
Mutual labels:  proxy
Awesome Node Utils
some useful npm packages for nodejs itself
Stars: ✭ 51 (-1.92%)
Mutual labels:  node-module
Sslkill
Forced Man-In-The-Middle HTTPs-Avoiding Reverse Proxy
Stars: ✭ 48 (-7.69%)
Mutual labels:  proxy
Aplay
A Better(Maybe) iOS Audio Stream、Cache、Play Framework
Stars: ✭ 44 (-15.38%)
Mutual labels:  proxy
V2ray Core
A platform for building proxies to bypass network restrictions.
Stars: ✭ 13,438 (+25742.31%)
Mutual labels:  proxy
Erlang Http Proxy
Nontrivial HTTP proxy server in Erlang
Stars: ✭ 42 (-19.23%)
Mutual labels:  proxy
Pythem
pentest framework
Stars: ✭ 1,060 (+1938.46%)
Mutual labels:  proxy
Is
Type check values
Stars: ✭ 1,011 (+1844.23%)
Mutual labels:  node-module
Ldap Auth Proxy
A simple drop-in HTTP proxy for transparent LDAP authentication which is also a HTTP auth backend.
Stars: ✭ 48 (-7.69%)
Mutual labels:  proxy
React Native Markdown Package
React native markdown package is a Library for implementing markdown syntax in React Native
Stars: ✭ 50 (-3.85%)
Mutual labels:  node-module

mockserver-client-node

Communicate with a MockServer from any node or grunt build

Build status Dependency Status devDependency Status

NPM

Community

  • Backlog:                     Trello Backlog
  • Freature Requests:  Github Issues
  • Issues / Bugs:           Github Issues
  • Chat:                           Join Slack

Getting Started

MockServer allows you to mock any system you integrate with via HTTP or HTTPS (i.e. (REST) services, web sites, etc). Please note that it is a third party project that needs java.

This npm module allows any grunt or node project to easily communicate with a running MockServer instance.

As an addition to this module for communicating with a running MockServer there is a second project that can be used to start and stop a MockServer called mockserver-node.

The MockServer client can be created as follows:

var mockServer = require('mockserver-client'),
    mockServerClient = mockServer.mockServerClient // MockServer and proxy client

Note: this assumes you have an instance of MockServer running on port 1080. For more information on how to do so check mockserver-node.

Setup Expectation

A simple expectation can be set up as follows:

mockServerClient("localhost", 1080)
    .mockSimpleResponse('/somePath', { name: 'value' }, 203)
    .then(
        function(result) {
            // do something next
        }, 
        function(error) {
            // handle error
        }
    );

A more complex expectation can be set up like this:

mockServerClient("localhost", 1080)
    .mockAnyResponse(
        {
            'httpRequest': {
                'method': 'POST',
                'path': '/somePath',
                'queryStringParameters': [
                    {
                        'name': 'test',
                        'values': [ 'true' ]
                    }
                ],
                'body': {
                    'type': "STRING",
                    'value': 'someBody'
                }
            },
            'httpResponse': {
                'statusCode': 200,
                'body': JSON.stringify({ name: 'value' }),
                'delay': {
                    'timeUnit': 'MILLISECONDS',
                    'value': 250
                }
            },
            'times': {
                'remainingTimes': 1,
                'unlimited': false
            }
        }
    )
    .then(
        function(result) {
            // do something next
        }, 
        function(error) {
            // handle error
        }
    );

For the full documentation see MockServer - Creating Expectations.

Verify Requests

It is also possible to verify that request were made:

mockServerClient("localhost", 1080)
    .verify(
        {
            'method': 'POST',
            'path': '/somePath',
            'body': 'someBody'
        }, 
        1, true
    )
    .then(
        function() {
            // do something next
        }, 
        function(failure) {
            // handle verification failure
        }
    );

It is furthermore possible to verify that sequences of requests were made in a specific order:

mockServerClient("localhost", 1080)
    .verifySequence(
        {
            'method': 'POST',
            'path': '/somePathOne',
            'body': 'someBody'
        },
        {
            'method': 'GET',
            'path': '/somePathTwo'
        },
        {
            'method': 'GET',
            'path': '/somePathThree'
        }
    )
    .then(
        function() {
            // do something next
        }, 
        function(failure) {
            // handle verification failure
        }
    );

For the full documentation see MockServer - Verifying Requests.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Changelog

All notable and significant changes are detailed in the MockServer changelog


Task submitted by James D Bloom

Analytics

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].