Skip to content

Debugging tools

Mock Sets

Record responses from captured traffic, a whole domain or a HAR file, and replay them without the network to demo, test or debug an app offline.

A mock set is a snapshot of an API’s responses. While it’s on, Cloak Proxy answers matching requests from the snapshot instead of the network, so an app behaves exactly as it did when you recorded it. Use mock sets to demo an app without Wi-Fi, to keep testing while a backend is down, or to reproduce a bug from a teammate’s HAR file.

  1. Use your app normally so Cloak Proxy captures the screens you need.

  2. In the sidebar, right-click the domain and choose Mock api.example.com Offline (the menu item shows the domain’s name).

    Cloak Proxy turns every captured response from that host into a mock set named api.example.com (offline), turns Mock Sets on and opens the set.

  3. Use the app again. Requests to the host are answered from the set, with a Mock badge in the traffic list. Nothing reaches the server.

  4. When you’re done, clear the set’s checkbox or turn Mock Sets off.

A mock set with one recorded response. With Offline on, nothing reaches api.example.com while the set is on.

  1. A mock set: its response count and hosts.
  2. Offline: unrecorded requests to these hosts get a 404.
  3. Match recordings regardless of the query string.
  4. Filter the responses by URL.
  5. A recorded response. Select it to edit it; clear its checkbox to skip it.
  6. New mock set from selected requests or a file.
The Mock Sets tool with one set holding a single 200 response for GET api.example.com/v1/users, Offline mode on and Ignore query strings off
From How The set is named
Selected requests Select requests in the traffic list, right-click one of them and choose Tools › Mock N Responses (or Mock This Response for one). Or search for Mock Selected Responses in Search Everything. After the request, or N requests from <host>
Selected requests, in the Tools window Click + under the list and choose From Selected Requests. N selected requests
A whole domain Right-click the domain in the sidebar and choose Mock … Offline. <host> (offline)
A file Click + and choose Import HAR or Session…, or click Import HAR or Session… when the list is empty. Accepts .har, .cloaksession, Charles .chlsj and .json files. The file name
A command line run cloakctl run --mock FILE answers requests from a recorded HAR or session. The file name

Each way turns Mock Sets on. Only requests with a response are recorded; encrypted tunnels and requests still in progress are skipped.

For each request, a mock set keeps the method, the full URL, the status code, the headers and the body.

  • The body is stored decompressed, so you can read and edit it.
  • Content-Encoding, Content-Length, Transfer-Encoding, Connection and Keep-Alive headers are left out. Cloak Proxy sets the right length when it replays the response.
Setting Default What it does
Name Shown in the list and in the offline 404 message.
Offline: answer unrecorded requests to these hosts with 404 On Requests to any host in the set that have no recording get a 404 instead of going to the server. The note below the toggle lists the hosts.
Ignore query strings when matching Off Matches /users?page=2 with a recording of /users?page=1.

With Offline off, recorded requests are answered from the set, and anything else goes to the real server.

An unrecorded request to a host in an Offline set gets:

Offline response
HTTP/1.1 404 Not Found
Content-Type: application/json
X-Cloak-Proxy: mock-miss
{"error":"No response recorded in mock set “api.example.com (offline)” for GET /v1/settings"}

Look for X-Cloak-Proxy: mock-miss to find screens you didn’t record.

Select a set to see its responses.

Column What it shows
On Clear it to skip this response.
Method The request method.
URL The full recorded URL.
Status The status code, red for 400 and above.
Size The body size.

Type in Filter URLs to narrow the table. Select a response and click the minus button next to the filter to remove it.

Select a response to edit it below the table:

Field Notes
Status code Any number; the reason phrase is shown next to it.
Headers Edit, Add or remove headers.
Body Text bodies are editable, with JSON validation, Format and Minify. Binary bodies show Binary body, N. It’s replayed as recorded. and can’t be edited.

Changes apply to the next matching request.

A request is answered from a set when its method and URL match a recorded response:

  • The method must be the same (case doesn’t matter).
  • The scheme and host are compared without case. Default ports (:443, :80) and #fragments are ignored.
  • The path and query values are compared exactly, including case.
  • Query parameter order doesn’t matter: ?b=2&a=1 matches a recording of ?a=1&b=2.
  • With Ignore query strings when matching on, the query string is ignored completely.
  • If the same request was recorded more than once, the most recent recording wins.
  • Responses whose On checkbox is cleared are skipped.

Sets are checked from the top of the list down, and the first set that answers wins (First matching set wins). Drag sets to change the order. Clear a set’s checkbox to skip it, or right-click it and choose Delete.

  • Map Local runs first: a matching Map Local rule wins over a mock set.
  • Mock Sets match the request after request scripts and the request breakpoint. Map Remote runs after Mock Sets, so a mocked request is never remapped.
  • Mocked responses still go through No Caching, response scripts, the response breakpoint and the download delay of Network Conditions. You can script small changes on top of a recording, or test the recording on a slow network.