Your progress is saved locally. to save it permanently.

0 of 4 steps0%

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.

1

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.

  1. Open the Postman desktop app and switch to your [Your name] - Native Git workspace.

  2. Confirm Local View is on and your deskly-api folder is still connected. The branch name shows in the bottom left.

  3. If you're not on a feature/ branch that has your collection (usually feature/deskly-collection or feature/deskly-openapi), open the Postman terminal and run:

    git fetch origin
    git checkout feature/deskly-collection

    If you used a different feature/ branch name in the OpenAPI module, checkout that one instead.

  4. Confirm the bottom-left branch name updates.

  5. In the left sidebar, expand Local Items → CollectionsDeskly API should appear. If you generated a spec, it should also show under Specs.

Troubleshooting

  • checkout fails — run git branch -a and use the feature/ branch you pushed earlier.
  • Collection still missing — re-run Part 1 Step 2, then git pull origin <your-feature-branch>.
2

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.

  1. Confirm Local View is still on.

  2. If the real Deskly server is still running from the first module (npm start on port 4000), 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.

  3. In the sidebar, click + → Mock.

  4. Name the mock Deskly Mock.

  5. When the mock opens, leave the default scenario selected.

  6. 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.

  7. 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.

3

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.

  1. In the left sidebar, click Files and expand postman/mocks/.
  2. Open config.yaml. Note the mock name, port, and the scenarios list. The default scenario is marked with default: true and points at a .js implementation file.
  3. Open the default scenario's .js file (or select the mock and use the Code pane). You should see an HTTP server and request-handling logic — often with // @endpoint comments for the routes the mock exposes.
  4. In the Code pane, notice you can call Postman pm helpers inside the handler. You won't deep-dive here, but know these exist when you need richer stand-in behavior:
HelperWhat it's for
pm.mockMatch incoming requests and send responses, including from saved Postman examples
pm.statePersist data across requests (e.g. a booking created with POST shows up on GET)
pm.datasetsQuery datasets and use that data when building responses
pm.test / pm.expectAssert on request or response data; results show up in mock logs
pm.environment / pm.globalsRead environment and global variables
  1. Optionally make one small, visible tweak so you own the file — for example, ensure GET /health returns 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.

4

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.

  1. Under Local Items → Mocks, select Deskly Mock.

  2. Click Start in the upper right.

  3. 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 from config.yaml; if that port is busy, Postman falls back to an OS-assigned port). Prefer a port other than 4000 so 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.

  4. 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 /health to the URL so the request is:

    GET http://localhost:<port>/health
  5. Click Send. Expect a successful response from your mock handler (often 200 with JSON). If you added a "mode": "mock" field earlier, you should see it here.

  6. 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.

  7. Optionally open the mock's Logs tab and confirm the request appears.

  8. 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 4000 unless 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 @endpoint comments, or re-prompt Agent Mode to add it.