Create a coded mock in Local View — JavaScript handlers under postman/mocks/ that stand in for Deskly so consumers (and CI) don't need the real Express process.
Switch to the Branch with Your Collection
Local View only shows Postman elements for the branch currently checked out. If the bottom-left branch reads main, your Deskly collection won't be in the sidebar yet.
-
Open the Postman desktop app and switch to your [Your name] - Native Git workspace.
-
Confirm Local View is on and your
deskly-apifolder is still connected. The branch name shows in the bottom left. -
If you're not on a
feature/branch that has your collection (usuallyfeature/deskly-collectionorfeature/deskly-openapi), open the Postman terminal and run:git fetch origin git checkout feature/deskly-collectionIf you used a different
feature/branch name in the OpenAPI module, checkout that one instead. -
Confirm the bottom-left branch name updates.
-
In the left sidebar, expand Local Items → Collections — Deskly API should appear. If you generated a spec, it should also show under Specs.
Troubleshooting
checkoutfails — rungit branch -aand use thefeature/branch you pushed earlier.- Collection still missing — re-run Part 1 Step 2, then
git pull origin <your-feature-branch>.
Create a Deskly Stand-in Mock
Create a coded mock that pretends to be Deskly for consumers of the API. Postman will generate a folder under postman/mocks/ with a config.yaml and a JavaScript scenario file. You'll use Agent Mode to scaffold Deskly-shaped handlers from your connected repo or collection — same approach as building the collection in the first module.
-
Confirm Local View is still on.
-
If the real Deskly server is still running from the first module (
npm starton port4000), stop it with Ctrl+C in that terminal. For the rest of this module you'll talk to the mock, not the Express app — that role switch is the point. -
In the sidebar, click + → Mock.
-
Name the mock
Deskly Mock. -
When the mock opens, leave the default scenario selected.
-
Open Agent Mode (right sidebar, or universal search →
> agent mode) and paste:Create request handlers for this mock that stand in for the Deskly API in my connected repo (or my Deskly API collection): GET /health (public), GET /desks, GET /desks/:id, GET /bookings, POST /bookings, GET /bookings/:id, and DELETE /bookings/:id. Authenticated routes should accept an X-API-Key header. Keep the responses simple JSON that looks like Deskly so a consumer collection can call the mock instead of the real server.
-
Review what Agent Mode proposes and approve (unless Auto-run is on). Expand Deskly Mock in the Code pane and confirm handlers appeared for the Deskly routes.
Expected outcome: Deskly Mock appears under Local Items → Mocks, and Files shows a folder under postman/mocks/ (often named after the mock) with config.yaml and at least one .js scenario file with Deskly-shaped handlers.
Meet the Mock Files and pm Helpers
Before you run anything, open the files Native Git wrote and skim the helpers you can use in the editor. You don't need to master every method — just know what's available when a static “always 200” stand-in isn't enough.
- In the left sidebar, click Files and expand
postman/mocks/. - Open
config.yaml. Note the mock name, port, and the scenarios list. The default scenario is marked withdefault: trueand points at a.jsimplementation file. - Open the default scenario's
.jsfile (or select the mock and use the Code pane). You should see an HTTP server and request-handling logic — often with// @endpointcomments for the routes the mock exposes. - In the Code pane, notice you can call Postman
pmhelpers inside the handler. You won't deep-dive here, but know these exist when you need richer stand-in behavior:
| Helper | What it's for |
|---|---|
pm.mock | Match incoming requests and send responses, including from saved Postman examples |
pm.state | Persist data across requests (e.g. a booking created with POST shows up on GET) |
pm.datasets | Query datasets and use that data when building responses |
pm.test / pm.expect | Assert on request or response data; results show up in mock logs |
pm.environment / pm.globals | Read environment and global variables |
- Optionally make one small, visible tweak so you own the file — for example, ensure
GET /healthreturns JSON that includes"service": "deskly"and a field like"mode": "mock"so you can tell the stand-in apart from the real app. Save the file (or let auto-save write it).
Learn more: Build API mocks with JavaScript and the pm.mock, pm.state, and pm.datasets references.
Expected outcome: You can explain where the mock lives on disk (postman/mocks/…) and name at least two pm helpers you'd reach for later.
Point a Consumer Request at the Mock
Prove the stand-in works the way a consumer would use it: start the mock, leave the real Deskly app stopped, and send a collection-style request at the mock URL.
-
Under Local Items → Mocks, select Deskly Mock.
-
Click Start in the upper right.
-
Once the mock is running, the local URL appears in the upper right next to the red Stop button — for example
http://localhost:4500(the port comes fromconfig.yaml; if that port is busy, Postman falls back to an OS-assigned port). Prefer a port other than4000so it's obvious you're not hitting the Express app. Use the copy icon in that URL bar if you want the address on the clipboard. -
Click the Open in a new request icon (external-link) in the same URL bar. Postman opens a new request with only the mock base URL filled in (for example
http://localhost:4500) — it does not include a path. Append/healthto the URL so the request is:GET http://localhost:<port>/health -
Click Send. Expect a successful response from your mock handler (often
200with JSON). If you added a"mode": "mock"field earlier, you should see it here. -
Optionally duplicate one of your Deskly API collection requests (for example List Desks), change only the base URL/port to the mock, keep
X-API-Key: demo-key, and Send — that's the consumer workflow in miniature. -
Optionally open the mock's Logs tab and confirm the request appears.
-
Click Stop in the upper right when you're done exploring in the UI — you'll start the same files again from the CLI in Part 3.
Troubleshooting
- Connection error — confirm the green status next to the URL bar shows the mock running, and you're using that displayed port (not
4000unless that's what the mock config says). - Accidentally hit the real app — if Deskly is still on
npm start, stop it; consumers in this module should only need the mock. - 404 — the handler may not define that path yet; try a route listed in the Code pane's
@endpointcomments, or re-prompt Agent Mode to add it.