API mocks right in the proxy — no separate server
Set server responses yourself without touching the backend or reconfiguring the app. Microkoi Bench serves your app the status, headers and body you set, and the request never goes to the server.
A mock in half a minute
- 1
Find the requests
Pick an exchange in traffic or check the branches you need in the endpoint tree — mocks are created for all of them at once.
- 2
Click “Create mock”
The mock gets the same method, host, path and the last recorded response. It is created turned off, so nothing is served too early, and clicking again does not create duplicates.
- 3
Edit and turn it on
Set the status, body and delay you need, save with ⌘S and turn the mock on with its toggle.
What mocks are for
Everything that is hard or slow to reproduce on a real server.
Rare errors
500, 503, 429 with Retry-After — see how your app copes with a failure your test environment never produces.
Slow responses
A delay in milliseconds shows how loading indicators and timeouts behave.
Empty lists
An empty cart, no notifications, no search results — without preparing test data.
Endpoints not built yet
Describe the response agreed with the backend team and start on the client right away.
Expired session
Set your own response to the token refresh and check how the app signs the user out.
Mocks from the endpoint tree
A button on a branch creates a mock for every method and path inside it, and a {id} template row creates one mock for any ID, even one that never showed up in traffic.
Visible in traffic
An exchange answered by a mock gets a blue cube in the first column of the table, and a button with the mock’s name in the exchange panel opens it in the editor.
Cases
A named subgroup overrides the status, headers and body of the base mocks. Switch the case and the proxy answers differently, without a restart.
Headless, in automated tests and CI
The
bench-program runs the same proxy with a case and no window, while your script switches cases and collects a report.mocks
How it works
Rules with path wildcards
A mock matches by method, host and path. Method and host can be left empty to match any. In the path, one asterisk stands for one segment and two asterisks for any tail.
/api/matchesusers/ * /api/but notusers/ 42 /api/users/ 42/ orders /cdn/matches everything under** /cdn/**/avatar.pngmatches a file with that name at any depth- Query parameters are ignored, and the host is compared without case or port
The most specific one wins
If several mocks match, the most specific wins: a path without wildcards beats one with wildcards, more exact segments beat fewer, and a set host and method beat “any”. No manual ordering is needed, and the result does not depend on file order.
The mock tree and groups
Mocks are shown as a tree by host and path segments: api.example.com › v1 › orders › GET Order list. A button on a host or folder turns on every mock inside if all are off, and turns them all off if at least one is on.
- So a group of mocks collected from traffic turns on with one click when the server is down, and turns off the same way
- The trash button on a branch deletes every mock inside after a confirmation that states how many
- Tree folders reflect the URL, not where files are stored: change the path in the editor and the mock moves to the right branch on its own
- Search covers the name, method, host and path, and branches with matches expand in full
- The “Collapse nested” button on a folder tidies the tree, and the whole tree works from the keyboard
Cases: other responses from the same mocks
Regular workspace mocks are the base responses. A case is a named subgroup that only overrides their responses: status, headers and body. One case is active, or none, just like one active environment: switching takes effect at once, without a restart or a save.
- Requests are still matched against the base mocks, so a case has no paths of its own. If no mock matches, the request goes to the real server
- A case is created from mocks checked in the tree: “Checkout/Delivery slot taken” and “Checkout/Success” are grouped under “Checkout”
- The context picker shows what you are editing, and a separate mark shows which case is answering right now, so you can edit one case while another is active
- A case tree can be narrowed to overridden endpoints, for example “Overridden: 3 of 40”
- Cases live in the workspace’s cases folder and go into git, while the active case is stored only on your computer
A console program for automated tests and CI
The bench- program ships next to the app on macOS, Windows and Linux and runs the same proxy with your mock responses and no window. Your app or automated test goes through the proxy, while a script switches cases and collects a report over the local control API.
- The
--no-mocksflag starts with mocks turned off: requests go to the real server, and aPUTrequest turns them on and off on the fly/v1/ mocks - A case is turned on and off with a request to
/v1/and takes effect from the next requestactive- case - The report lists the mock responses that were served and how many times, and counters of in-flight requests and idle time tell you when the app has finished loading data
- The proxy listens only on
127.0.0.1, the control API requires a session token, the program never changes the workspace, and several instances can run side by side - The program names damaged case data in warnings, and a case whose body file is missing is not turned on: your test never gets an empty response instead of the expected one
bench-mocks serve --workspace ./api-space --case "Delivery slot taken"Mocks are files
Each mock is stored as a .mock.json file in the workspace’s mocks folder, and the response body as a separate file next to it: real JSON, an image, a PDF or an archive. All of it goes into git along with requests and notes. Renaming a mock renames its files but does not break links to it from traffic.
- The body can be typed as text or picked from any file; images show a preview
- A mock can have a plain-language description: what it is for and when it answers
- The “Serve as a download” toggle adds the right header
- Edits to the body file in another editor and mocks pulled from git are picked up right away
- A broken file is skipped and does not break the list
- Mocks from different workspaces never overlap
A mock that keeps up with the backend
Above a JSON body, the mock editor has a “Model” view: the body’s fields and their types. Bench checks them against the contract of the real endpoint it built from recorded traffic. If the backend changed its response, the “Mock differs from the contract” bar names the field, and “Open contract” takes you to the endpoint in “Traffic”.
- While there is a mismatch, a yellow dot shows on “Model” — you can see it while editing the body too
- A mock is matched by host, method, path template and status code
- Chaos applies to mock responses too: a delay, an error or a dropped connection lands on top of the response you set
The editor warns you in advance
If a mock cannot match, you see it right away: when the proxy is stopped or when the mock’s host is not recorded in the workspace. For a JSON body the editor highlights syntax, validates it and can format it.
- Edits take effect after saving; the toggle turns the mock on immediately
- When you switch to another mock with unsaved edits, the app asks whether to save them
Questions and answers
Do I need to run a separate mock server?
Not for mocks. They work inside the Bench proxy: an app that goes through the proxy gets the response you set at the same address as usual. If you need a separate API on its own port that the app calls directly, that is what mock servers are for.
Does the request reach the real server when a mock answers?
No. The proxy answers instead of the server, and the exchange is recorded in traffic with your app’s request body, the mock’s response and the time including the delay.
Why doesn’t my mock work?
Check that the proxy is running and that the mock’s host is recorded in the workspace: a connection to a host excluded in “Recording” goes through an opaque tunnel, and no response can be set in it. The mock editor warns about both situations.
Can I share mocks with my team?
Yes. Mocks are stored as files in the workspace’s mocks folder, and cases in the cases folder. Commit them, and your teammates get the same rules. Which case is active does not go into git.
How is a case different from a mock?
A mock answers a request that matches its method, host and path. A case only changes the response of existing mocks: status, headers and body. A case has no paths of its own, and without an active case mocks answer as usual.
Can I serve mock responses without the app window?
Yes, that is what the bench- program is for. It starts the proxy with the chosen case and prints the proxy address and the control API token, while a script turns cases on and off and collects the report. It fits automated tests and continuous integration.
How do I compare my app’s behavior with and without mocks?
In the app, turn off the mock toggles or clear the active case. In bench-, start the proxy with the --no-mocks flag or send PUT with {"enabled":false}: no mock answers, and requests go to the real server.