Installation


Create a sample mock in the default directory (./mockaton-mocks)

mkdir -p         mockaton-mocks/api
echo "[1,2,3]" > mockaton-mocks/api/foo.GET.200.json

Option 1: CLI

Requires Node.js v22.18+. Node includes npx, which installs and runs Mockaton.

npx mockaton --port 4040

Test it

curl localhost:4040/api/foo

Option 2: 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

Test it:

curl localhost:2020/api/user

Option 3: For Node Projects

npm install mockaton --save-dev

In your package.json:

"scripts": {
  "mockaton": "mockaton --port 4040"
}

Option 4: Programmatic Launch

import { Mockaton } from 'mockaton'
import config from './mockaton.config.js'

const server = await Mockaton(config)