0.5.2 • Published 7 years ago

node-http-mock v0.5.2

Weekly downloads
6
License
MIT
Repository
-
Last release
7 years ago

node-http-mock

A HTTP mock server for node.js

Usage

Install it:

npm install node-http-mock -g

And run this command in your termial:

mock -t [api host] -p [local port] -c [config file]

Config File

You can use config file instead of command line options:

// mock.config.js
module.exports = {
  port: 5000,
  verbose: true,
  proxy: {
    target: 'api host',
    changeOrigin: true,
  },
  mock: {
    '/url_a': {},
    '/url_b': {},
  },
}

Run this command to use the config file:

mock -c # default config file mock.config.js
mock -c my.mock.config.js # customize config file

Record & Replay

node-http-mock can construct mock data from real HTTP streams.It identify APIs according to request url, request method and query strings.

[method] [url] ? [query string]

Use -r option to recording these responses as ordinary JSON files in .mock/:

mock -r [directory path]

Press Crtl-C will terminate recording and create index.js tracing the JSON files.After that you can import the index.js into your config file manually:

module.exports = {
  // ...
  mock: require('./.mock/index.js'),
}

Options

Run this command to see a list of all available options:

mock --help

License

MIT © BinRui.Guan

0.5.2

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.11

7 years ago

0.4.10

7 years ago

0.4.9

7 years ago

0.4.8

7 years ago

0.4.7

7 years ago

0.4.6

7 years ago

0.4.5

7 years ago

0.4.4

7 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago