Installation
Requires Node.js v22.18+
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
npx mockaton --port 4040
Test it:
curl localhost:4040/api/foo
Option 2: NPM
npm install mockaton --save-dev
In your package.json:
"scripts": {
"mockaton": "mockaton --port 4040"
}
Option 3: Programmatic Launch
import { Mockaton } from 'mockaton'
import config from './mockaton.config.js'
const server = await Mockaton(config)
Option 4: 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