v12.3.0

HTTP mock server for simulating APIs — ideal for triggering difficult to reproduce backend states.

Overview

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

Quick Start (Docker)

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

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

Dashboard

Mockaton Dashboard

Dashboard Features

On the other hand, there’s a Programmatic HTTP API, which is useful for setting up automated tests.

Multiple Mock Variants

Each route can have multiple mock files. You can do that by adding comments in parentheses to the filename:

api/user(at step 1.0).GET.200.json
api/user(at step 1.1).GET.200.json

Or, based on the response status code. Comments are optional in these cases:

api/login(invalid attempt).POST.401.json
api/login(locked out user).POST.423.json

You can write JSON mocks in JavaScript or TypeScript

An Object, Array, or String is sent as JSON

api/foo.GET.200.js

export default { foo: 'bar' }

If you need more control, you can use Functional Mocks.