Also see Wiremocks
“Mockoon is the easiest and quickest way to design and run mock REST APIs. - mockoon.com”
Create Local
Using the Mockoon desktop application create a new local environment and save it locally, I use
C:\dev\SWEETAPI\.localdev\mock-server
and call the json file something related to the mocks, eg:mock-netsuite.json
An example route could be
GET /contact
with response
1 | { |
- You can then use Mockoon desktop to run the collection but its more useful to be part of the local development pipeline running in a container. Docker Compose is a good candidate because you will probably add other service mocks, cache stores, databases ect
You could orchestrate the commands with Make or just use Powershell per the eamples below.
Define the docker-compose.yml
file, create a service using the image mockoon/cli and point the volume to the location of the Mockoon local environment
1 | services: |
- Run the mocks using Powershell, create
run-local.ps1
in the root and execute the docker compose command
1 | docker compose up --wait mockoon |
Here I explicily called the service mockoon
and if this was your only mock, you could just run the container, this came from the docs:
1 | docker run -d --mount type=bind,source=/home/your-data-file.json,target=/data,readonly -p 3000:3000 mockoon/cli:latest --data data --port 3000 |