HTTP mock server for simulating APIs — ideal for triggering difficult to reproduce backend states.
Convention
A given directory is scanned for filenames following a convention similar to the URLs. For example, for /api/company/123, the filename could be:
my-mocks-dir/api/company/[id].GET.200.json
Each route can have multiple mock variants. You can do that by adding comments in parentheses:
api/user(at step 1.0).GET.200.json api/user(at step 1.1).GET.200.json
Similarly, you can use different response status codes. Comments are optional in these cases:
api/login(invalid attempt).POST.401.json api/login(locked out user).POST.423.json
Quick Start (Docker)
This will spin up Mockaton with the sample directories included in the repo mounted on the container.
git clone https://github.com/ericfortis/mockaton.git --depth 1
cd mockaton
make docker
Dashboard
On the dashboard, you can:
- Delay responses 🕓
- Select a mock variant for a particular route
-
Trigger an autogenerated
500error, and cycle it off (e.g., for testing retries) -
Bulk Select mocks by comments
to simulate the complete states you need.
On the other hand, there’s a Programmatic HTTP API, which is useful for setting up automated tests.