1.10.0 • Published 7 years ago

mock-servers-js v1.10.0

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

Server mocking library based on WireMock library

Pre-requisites:

  • Java installed (WireMock server is Java .jar)

Get library:

  npm install mock-servers-js

Run server:

  var mock_servers = require('mock-servers-js');
  mock_servers.startWireMock('1001', null);

Setup new mapping from js:

  var request = {
      "request": {
        "method": "GET",
        "url": "/endpoint/for/mocking"
      },
      "response": {
        "status": 200,
        "jsonBody": {
          "mock_servers_js": "Hello :)"
        },
        "headers": {
          "Content-Type": "application/json"
        }
      }
    };

  mock_servers.setNewMappingForPort('1001', request);

Setup new mapping with curl:

  curl -X POST \
  --data '{ "request": { "url": "/get/this", "method": "GET" }, "response": { "status": 200, "body": "Here it is!\n" }}' \
  http://localhost:1001/__admin/mappings/new

Check mappings:

  http://localhost:1001/endpoint/for/mocking
  http://localhost:1001/get/this

Shutdown server from js:

  mock_servers.shutDownWireMock('1001');

Server will be started on port '1001'. Use WireMock api to setup new mappings: http://wiremock.org/docs/api/

1.10.0

7 years ago

1.9.0

7 years ago

1.8.0

7 years ago

1.7.0

7 years ago

1.6.0

7 years ago

1.5.0

7 years ago

1.4.0

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago