WireMock API Mocking Visualizer
This free WireMock visualizer shows how API mocking works: match an incoming request, return a stubbed response, and simulate faults or latency so your tests never depend on a real, flaky third-party service. It is built for SDETs who need reliable API test automation and want to explain mocking clearly in interviews.
Why mock an API at all
Real dependencies make tests slow and flaky: the service is down, rate-limited, returns changing data, or costs money per call. A mock replaces it with a fast, deterministic stand-in you control, so your test verifies your code, not someone else's uptime.
Request matching and stubbing
A WireMock stub pairs a request matcher with a response. You match on method, URL, headers, query params and body (exact, regex or JSON path). When a request matches, WireMock returns the configured status, headers and body. More specific stubs win, so you can define a default and override it for edge cases.
Simulating faults and latency
The real value for testing is the unhappy path. WireMock can return 500s, malformed responses, connection resets, or add fixed/random delays — so you can prove your retry logic, timeouts and circuit breakers actually work, which is nearly impossible against a real service.
Stateful and verification
Scenarios let a stub change behaviour across calls (first call returns "pending", second "complete"), and WireMock can verify that your code made exactly the calls you expected — the mock doubles as an assertion on outbound requests.
How to use this tool
- Define a request matcher (method + URL) in the tool.
- Attach a stubbed response with a status and JSON body.
- Send a matching request and watch WireMock return the stub.
- Inject a delay or a 500 error and see how a client should handle it.
Worked example
A WireMock stub returns a fixed JSON response for a matching request:
stubFor(get(urlEqualTo("/users/1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody("{ \"id\": 1, \"name\": \"Naveed\" }")
.withFixedDelay(200)));
Any GET /users/1 now returns this body after a 200ms delay — no real service needed. Common mistakes to avoid
- Over-matching (matching on a volatile header) so the stub silently stops matching.
- Only stubbing happy paths and never testing 500s, timeouts or malformed responses.
- Baking mocks so deep that tests pass while the real integration is broken.
- Forgetting to reset stubs between tests, leaking state across cases.
Frequently asked questions
What is WireMock?
WireMock is a tool for mocking HTTP APIs: it matches incoming requests and returns configured (stubbed) responses so tests run without real dependencies.
Why mock an API in tests?
To make tests fast, deterministic and independent of a real service's uptime, rate limits or changing data, and to simulate errors that are hard to trigger for real.
How does request matching work?
WireMock matches on method, URL, headers, query params and body using exact, regex or JSON-path rules; the most specific matching stub wins.
Can WireMock simulate failures?
Yes — it can return error statuses, malformed responses, connection faults and fixed or random delays, which is ideal for testing retries, timeouts and circuit breakers.
Is this WireMock tool free?
Yes, it runs in your browser with nothing to install and is free for learning and interview prep.