README
Smocker
- Intro
- Install
- API
- Configuration
- Resources & Url Matching
- Mock Resources
- Example
- Binary Responses
- Fail-rate Responses
- Change Log
Intro
A very simple HTTP server mocker loading mocked data from node modules.
- write resources in an easy to manage folder structure
- resources are simple node modules so they can be simple JSON or contain logic using functions
- supports CORS for easy use during development
- supports jsonp
Smocker relies on a simple folder and file naming convention so there is hardly any code needed to get started.
Install
npm install smocker --save-dev
API
start (config)
Start a new instance of Smocker with the provided or default configuration. Internally starts a new http server. Pass in a configuration object to override one or more of the defaults (See the configuration section below for details).
returns a Promise that's resolved with a function that's when called will stop the running HTTP server.
setDefaults (config)
changes the root defaults object for all future instances. Use this method to update some or all of the defaults smocker uses when starting a new instance.
returns a clone object of the current defaults.
restoreDefaults ()
restores the defaults object used to its original state.
returns a clone object of the restored defaults.
Configuration
you can pass in a configuration object with the following parameters:
port - the server port to use (default: 9991)
resources - the path to where the resources for the responses will be loaded from (default: "./resources")
requestPrefix - the prefix to use for (all) requests when matching the url of an incoming request (default: "")
dynamicSymbol - the symbol to use in the folder name to denote the dynamic/optional part(s). Must be a valid file name character (default: "