LLensLogger / Docs
Documentation/ Mock Network Responses

NETWORK MOCKING

Control the response your app sees.

Create a mock rule from a captured call or add one from the Mocks tab. Match a request by its full URL and HTTP method, then return a custom status, headers, and body—or simulate a network failure.

STEP 01

Start with a captured request

  1. Open the Lens FAB and go to the Network tab.
  2. Find the request you want to replace, then tap it to inspect its details.
  3. Choose Mock this. The editor starts with that request's URL and method and, when available, the captured response status, headers, and body.
Network response detail with Mock this action
Inspect a captured response, then start a mock from this request

You can also open the Mocks tab and tap the plus button to create a rule manually.

STEP 02

Configure the rule

Set the request match and the response the app should receive:

  • Enabled: turn the rule on or off.
  • URL: full request URL to match exactly.
  • HTTP method: method to match; comparison ignores letter case.
  • Response delay: time to wait before returning the result, in milliseconds.
  • Status code: synthetic response status from 100 through 599.
  • Response headers: add, edit, or remove header name/value pairs.
  • Response body: response text returned to the app, often JSON.
Mock response editor with response headers and JSON body
Editor opened from a captured request, with response headers and body prefilled

STEP 03

Save the rule and replay the call

  1. Tap Create mock. The rule appears in the Mocks list.
  2. Make the same request again from your app.
  3. Check the screen or state that consumes the response, then open Network history to inspect the result.
Mocks tab showing an enabled POST rule
Enabled rule in the Mocks tab
Consumer screen showing the mocked response body
The consumer receives the configured status and response body

Mocked calls are marked with a MOCK badge in the Network history. From the Mocks tab you can toggle a rule, edit it, or delete it.

FAILURE AND LOADING STATES

Simulate failures or slow responses

Turn on Simulate network failure to make a matched request throw a synthetic I/O failure. Use this to exercise your app's retry, error, and empty-state behavior. Add a response delay to test loading indicators; the configured delay is applied before either a mock response or simulated failure.

When failure simulation is enabled, status, headers, and body fields are disabled because no response is produced.

Mock editor configured to simulate a network failure
Failure mode and request match
App showing a simulated request failure
Failure surfaced to the consumer

HOW MATCHING WORKS

Match the exact request

A rule applies when it is enabled, the complete request URL equals the rule URL, and the HTTP method matches without regard to case. If there are multiple enabled rules with the same URL and method, the first matching rule is selected; keep only the scenario you want enabled for a given match.

RULE MATCHenabled
+ exact full URL
+ same HTTP method
synthetic result

Rules are saved locally by LensLogger and are available again when the app is reopened.

TROUBLESHOOTING

If the live response still appears

  • Confirm the rule is enabled in the Mocks list.
  • Compare the rule URL to the full URL sent by the request, including scheme, host, path, and query string.
  • Check the HTTP method.
  • Make sure the request uses the Ktor or OkHttp client configured with LensLogger.
  • If you have duplicate enabled rules for the same URL and method, disable the rules for other scenarios.

For help finding and inspecting calls, see the Network Visualizer guide.