Giter VIP home page Giter VIP logo

mockserver-client-node's Introduction

mockserver-client-node

Communicate with MockServer from any node or grunt build

Build status Dependency Status devDependency Status Code Climate

NPM

For chat room: Gitter

Getting Started

MockServer is for mocking of any system you integrate with via HTTP or HTTPS (i.e. services, web sites, etc).

This npm modules is allows any grunt of node project to easily communicate with the MockServer.

An addition to this module for communicating with the MockServer there is also a grunt task that can be used to start and stop MockServer from grunt called mockserver-grunt.

The both the MockServer and proxy clients can be created as follows:

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

Note: this assumes you have an instance of MockServer running on port 1080 for more information on how to do this see mockserver-grunt.

Setup Expectation

Then an simple expectation can be setup as follows:

mockServerClient("localhost", 1080).
    mockSimpleResponse('/somePath', { name: 'value' }, 203);

Or a more complex expectation can be setup as follows:

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
        }
    }
);

For the full syntax support see MockServer - Creating JavaScript Expectations.

Verify Requests

It is also possible to verify that request were made as follows:

mockServerClient("localhost", 1080).verify(
    {
        'method': 'POST',
        'path': '/somePath',
        'body': 'someBody'
    }, 1, true);

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.

Release History

Date Version Description
2014-28-10 v0.0.1 Initial release
2014-28-10 v0.0.2 Fixed module naming
2014-28-10 v0.0.3 Fixing module loading
2014-28-10 v0.0.4 Fixing badges
2014-01-11 v1.0.0 Cleaned code & removed duplication
2014-02-11 v1.0.1 Added wercker build process
2014-21-11 v1.0.2 Fixed asynchronous errors
2014-04-12 v1.0.3 Improved connection error handling
2014-04-12 v1.0.4 Supporting protractor based promises
2015-04-06 v1.0.5 Upgrading dependencies
2015-06-02 v1.0.6 Improved clear and dumpToLog options
2015-09-27 v1.0.7 Fixed error with query parameter handling
2015-09-27 v1.0.8 Fixed documentation
2015-09-28 v1.0.9 Fixed documentation again
2015-10-11 v1.0.10 Added retrieve requests or expectations
2016-09-27 v1.0.11 Updated dependencies
2016-10-09 v1.0.12 Resolved issues with dependencies
2017-04-30 v1.0.13 Added websocket (i.e. method callbacks)
2017-05-03 v1.0.14 Backward compatibility for mockAnyResponse
2017-05-03 v1.0.15 Improving promise logic for protractor
2017-05-04 v1.0.16 Removed grunt peer dependencies

Task submitted by James D Bloom

mockserver-client-node's People

Contributors

bitdeli-chef avatar jamesbloomnektan avatar jamesdbloom avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.