Socket
Book a DemoInstallSign in
Socket

@inloopx/mockserver

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@inloopx/mockserver

Easily mock your webservices while testing frontends.

1.2.4
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

mockserver

Build Status

mockserver is a library that will help you mock your APIs in a matter of seconds: you simply organize your mocked HTTP responses in a bunch of js files and it will serve them like they were coming from a real API; in this way you can write your frontends without caring too much whether your backend is really ready or not.

Installation

Mockserver can be installed globally if you need to run it as a command:

$ npm install -g mockserver

$ mockserver -p 8080 -m test/mocks
Mockserver serving mocks under "test/mocks" at http://localhost:8080

or as a regular NPM module if you need to use it as a library within your code:

npm install mockserver

then in your test file:

var http    =  require('http');
var mockserver  =  require('mockserver');

http.createServer(mockserver('path/to/your/mocks')).listen(9001);

This will run a simple HTTP webserver, handled by mockserver, on port 9001.

At this point you can simply define your first mock: create a file in path/to/your/mocks/example-response called GET.js:

const status = 200

const headers = [
  "Access-Control-Allow-Origin: *",
]

const body = {
  OK: Math.random() < 0.5
}

module.exports = {
  headers,
  status,
  body
}

If you open your browser at http://localhost:9001/example-response you will see something like this:

example output

And it's over: now you can start writing your frontends without having to wait for your APIs to be ready, or without having to spend too much time mocking them, as mockserver lets you do it in seconds.

Keywords

test

FAQs

Package last updated on 11 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.