Fake API Server
This tool allows you to register collections of arbitrary endpoints to mock responses for against the Fake API Server, allowing you to easily test your code end-to-end.
Pair with the Fake API Server for easy collection registration.
View the API Documentation to get a better idea of how to use the Fake API.
A server instance has been set up at https://node-fake-api-server.herokuapp.com/.
Schema
server: fake-api.js # Optional, may provide or override via CLI
external_id: readme-example # Optional.
endpoints:
- method: get
path: /test
headers:
X-Bar: blah # require X-Bar to be set to blah.
query_parameters:
biz: baz # Require ?biz=baz
response_mode: incremental # or random.
responses:
- status: 200
content: Foo!
content_type: text/plain
delay: 0 # or any value up to 60000 (60 seconds)
headers:
server: me!! # define response headers
Usage
npm install -g node-fake-api-client
fake-api register -s https://node-fake-api-server.herokuapp.com/ examples/sample.yaml
{
"username": "935c5ba7-bff1-47f8-a9bd-a855c0ecadb0",
"password": "951fa676-8304-4e2a-b854-9d00beecd844",
"auth_token": "OTM1YzViYTctYmZmMS00N2Y4LWE5YmQtYTg1NWMwZWNhZGIwOjk1MWZhNjc2LTgzMDQtNGUyYS1iODU0LTlkMDBiZWVjZDg0NA==",
"endpoints": [
{
"method": "get",
"path": "/test",
"responses": [
{
"status": 200,
"content": "{\"foo\": \"bar\"}",
"content_type": "application/json",
"delay": 0
}
],
"response_mode": "incremental"
}
]
}