Skip to content

Mock a dependency without VPN

Goal: your micro calls a core you don’t want (or can’t) launch. You mock it: MicroLab responds for it with what you define.

In the scenario’s Dependencies panel, set that dependency to mock. From then on, your micro’s calls to that core are handled by MicroLab’s mock server.

You have two paths, depending on whether you prefer to get ahead or react:

Proactive (from OpenAPI). In the Mocks section, create a stub for that service. If it declares OpenAPI, select the operation and MicroLab generates a body template; if not, you write it by hand. See Mocks section.

Reactive (from a real call). Launch the scenario and let your micro call. The request appears in the Mock calls dock; turn it into a stub with one click and edit it. See Mock calls dock.

An endpoint can have several variants (a 200, a 500, with latency…). The one that is served is marked with the toggle. Changes apply with hot reload: you don’t need to restart anything.

You can check what a mock would respond without launching the scenario: in the CLI, microlab mock probe <method> <path>.