Skip to content

ericfortis/mockaton

Repository files navigation

Mockaton

An HTTP mock server for simulating APIs with minimal setup — ideal for testing difficult to reproduce backend states.

NPM Version Test codecov

Overview

With Mockaton, you don’t need to write code for wiring up your mocks. Instead, 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

Dashboard

Mockaton Dashboard

On the dashboard you can:

  • Select a mock variant for a particular route
  • 🕓 Delay responses
  • Trigger an autogenerated 500 error
    • …and cycle it off (for testing retries)

Nonetheless, there’s a programmatic API, which is handy for setting up tests (see Commander API section below).


Quick Start (Docker)

This will spin up Mockaton with the sample directories included in this repo mounted on the container.

mockaton-mocks/ and mockaton-static-mocks/

git clone https://github.com/ericfortis/mockaton.git --depth 1
cd mockaton
make docker

Dashboard: http://localhost:2020/mockaton

Test it:

curl localhost:2020/api/user

License

MIT