API mocking with latency simulation
Data as of Oct 21, 2026
Reviewed by Dimitry Apollonsky
Which brands AI mentions
Complex simulations with templating, stateful behavior, and hosted or local options.
Fine-grained latency controls for individual developers’ mock environments and routes.
Presented as a platform to explore, without a specific testing use.
Mentioned in · Jul 5 – Oct 21, 2026
ChatGPT SearchChatGPT SearchGoogle AI ModeGoogle AI Mode
Widest split: Mockoon, 86% on ChatGPT Search and 75% on Google AI Mode.
- 1WireMockChatGPT Search 95%Google AI Mode 100%
- 2MockoonChatGPT Search 86%Google AI Mode 75%
- =3BeeceptorChatGPT Search 38%Google AI Mode 48%
- =3MSW (Mock Service Worker)ChatGPT Search 48%Google AI Mode 38%
- =3PostmanChatGPT Search 47%Google AI Mode 38%
Questions and answers
Google AI ModeOct 21, 2026
Yes, several powerful tools let you mock API responses with custom delays and failure conditions to test system resilience. Popular options include WireMock, Prymock, Hoverfly, Mountebank , and Toxiproxy (which works at the TCP network layer rather than HTTP).
Top API Mocking and Resilience Tools
- WireMock : A flexible tool for stubbing and recording HTTP responses. It lets you set fixed or random delays and return custom error status codes (like 500 or 503) to test timeout handling and error recovery. You can run it via Java, Docker, or standalone.
- Toxiproxy : A proxy designed for testing network conditions. Instead of mocking the API content, it injects latency, bandwidth limits, and connection cuts directly into TCP connections. It works well alongside real or mocked backends.
- Hoverfly : A lightweight and fast API simulation tool. It allows you to capture real traffic and replay it with simulated latency, or design failure scenarios using its middleware support.
- Mountebank : A cross-platform tool for multi-protocol test doubles. It supports HTTP, TCP, and SMTP, letting you script complex response behaviors, inject injection delays, and simulate flaky network behaviors.
Would you like to see a quick configuration example for one of these tools, or do you need recommendations based on a specific test environment (like CI/CD pipelines vs. local development)?
ChatGPT SearchOct 21, 2026
Yes — there are several tools specifically designed to mock API responses with configurable latency, errors, timeouts, and other failure conditions. They're useful for resilience testing, including retry logic, circuit breakers, graceful degradation, and handling slow or unavailable dependencies.
The best choice depends on whether you want to simulate failures locally during development, run automated integration tests in CI/CD, or inject faults into a running distributed system.
Tools worth considering
1. WireMock
(Best general-purpose choice)
A flexible HTTP mock server for local development, automated tests, and CI pipelines. Supports fixed and randomized delays, HTTP error codes, empty responses, malformed data, and connection resets.
Best for: Testing retry policies, timeout handling, fallback responses, and application behavior under slow or failing APIs.
2. MockServer
A strong option when you need precise, programmable failure scenarios. It supports fixed or random latency, configurable error rates, connection drops, malformed responses, and fault injection against proxied upstream traffic.
Best for: Integration tests and controlled experiments against mocked or real downstream services.
3. Toxiproxy
Unlike a traditional API mock, Toxiproxy sits between your application and a real dependency. It can introduce latency and jitter, restrict bandwidth, drop packets, time out connections, and simulate connection resets.
Best for: Testing how your application behaves when the network or a real downstream service becomes unreliable.
4. Hoverfly
Provides API simulation, traffic capture and replay, and configurable delays, errors, and rate limits. It can replace external dependencies with reusable simulations.
Best for: Replaying realistic API traffic and testing integrations without repeatedly calling external services.
5. Mountebank
Supports HTTP, HTTPS, and TCP imposters, with delayed responses and fault conditions such as connection resets or corrupted data.
Best for: Teams that need service virtualization across several protocols, not just REST APIs.
Fault simulation documentation
Quick comparison
Capability WireMock MockServer Toxiproxy Hoverfly Return custom JSON Yes Yes No — network proxy Yes Fixed latency Yes Yes Yes Yes Randomized latency Yes Yes Latency + jitter Configurable HTTP 500/503 responses Yes Yes Not its primary purpose Yes Connection drops/resets Yes Yes Yes Fault simulation Proxy real dependencies Yes, conditionally Yes Yes Yes Best fit API-level tests Programmable fault tests Network failures Traffic replay Sources: WireMock, MockServer, Toxiproxy, Hoverfly.
Example: simulate a slow or failing API
With WireMock, you can configure a mocked endpoint to return a successful JSON response after a two-second delay:
json{ "request": { "method": "GET", "url": "/api/orders" }, "response": { "status": 200, "fixedDelayMilliseconds": 2000, "headers": { "Content-Type": "application/json" }, "jsonBody": { "orders": [] } } }You can then create separate scenarios for:
- Slow response: 2-second or randomized delay.
- Transient failure: HTTP 503 on selected requests, followed by HTTP 200.
- Timeout: Delay beyond your client's configured timeout.
- Network failure: Reset the connection instead of returning an HTTP response.
- Rate limiting: Return HTTP 429 with a
Retry-Afterheader.
WireMock supports response delays and low-level HTTP fault simulation; connection-level failures may require a fault configuration rather than an ordinary status response.
My recommendation
Start with WireMock if you want a straightforward way to define API responses and latency in automated tests. Choose MockServer if you want more programmable, probabilistic fault injection, or Toxiproxy if you need to test network behavior against real services.
One question that would help narrow this down: What environment are you testing?
1. Testing environment
Local development
Integration tests / CI pipeline
Staging or distributed system
Production-like chaos testing
2. Protocol
REST / HTTP
gRPC
TCP / database connections
Multiple protocols
3. Deployment preference
Self-hosted / open source
Hosted / managed
Either
[Find the best fit]
Sources cited in this answer16
- wiremock.orgSimulating Faults | WireMock
- wiremock.orgWireMock - flexible, open source API mocking | WireMock
- wiremock.orgWireMock - flexible, open source API mocking | WireMock
- wiremock.orgSimulating Faults | WireMock
- mock-server.comMockServer — Mock any HTTP service. Record traffic. Now with MCP for AI assistants.
- mock-server.comChaos Testing & Fault Injection | MockServer
Google AI ModeOct 19, 2026
Mocking API endpoints for resilience testing (such as testing circuit breakers, retries, timeouts, and fallback states) requires a tool capable of fault injection —specifically, artificial latency and HTTP error codes.
Top Tools for API Fault Injection
- WireMock : Excellent for programmatic and code-driven testing (Java, JUnit, or standalone server/Docker). It supports fixed or random delays and specific HTTP status faults.
- MockServer : Powerful for both standalone mocking and acting as a proxy to inject latency, connection drops, and error codes (500, 503, 429) deterministically or probabilistically.
- Mockoon : A lightweight, user-friendly desktop and CLI tool great for visually setting up latency and rule-based response status codes per route.
- Toxiproxy : A TCP proxy specifically built for chaos and resilience testing. Instead of mocking the HTTP layer, it sits between your app and the real database/API to manipulate network conditions (latency, bandwidth limitation, toxic connection drops).
Implementation Examples
1. Using WireMock (JSON Stub / Code)
You can configure a delayed response and an error code using WireMock's mapping configuration:
2. Using MockServer (Chaos Profile / Fault Injection)
MockServer allows you to attach a declarative profile to simulate dropped connections or percentage-based failures:
Recommended Best Practices
- Test Incrementally: Start with deterministic single-error triggers (e.g., a hard 500 or a 5s timeout) to ensure your basic error-handling and fallback logic execute properly.
- Introduce Probabilistic Failure: Progress to injecting intermittent failures (e.g., 10% packet loss or random 429 Rate Limit responses) to test complex client retry storms and jitter algorithms.
- Validate Recovery: Ensure your application properly recovers and closes circuit breakers once the mock endpoint returns to a healthy 200 OK state with zero latency.
If you'd like to dive deeper, let me know:
- What language or framework your application is written in
- Which specific scenario you are trying to test (e.g., timeout handling, exponential backoff, or circuit breaking)
I can provide a tailored configuration for your exact tool stack.
ChatGPT SearchOct 19, 2026
The most reliable way to mock API endpoints for resilience testing is to use a dedicated mock server that lets you control HTTP error responses, response latency, timeouts, and connection failures. Then run your application or integration tests against those controlled failures and verify that retries, circuit breakers, fallbacks, and timeout handling work as expected.
1. Choose a fault-injection tool
WireMock
(Best starting point)
Mock specific endpoints and configure HTTP status codes, fixed or randomized delays, and malformed responses or connection resets. Good for repeatable API integration tests and CI pipelines.
Docs: Simulating faults ·
MockServer
Useful for more advanced scenarios, including configurable error rates, response delays, malformed responses, and dropped connections.
Docs:
Toxiproxy
Best when you need to simulate network-level problems rather than just return an HTTP error: latency, jitter, bandwidth restrictions, dropped traffic, and connection resets.
Docs:
WireMock is a strong first choice if you primarily test HTTP APIs. Toxiproxy complements it when you need to reproduce failures at the network layer.
2. Configure endpoints with specific failures
With WireMock, you can define mappings as JSON files or register them through its admin API. For example, the following mappings simulate a server error and a slow successful response.
json[ { "request": { "method": "GET", "url": "/api/orders/500" }, "response": { "status": 500, "jsonBody": { "error": "INTERNAL_SERVER_ERROR", "message": "Simulated server failure" }, "headers": { "Content-Type": "application/json" } } }, { "request": { "method": "GET", "url": "/api/orders/slow" }, "response": { "status": 200, "fixedDelayMilliseconds": 3000, "jsonBody": { "id": "order-123", "status": "processing" }, "headers": { "Content-Type": "application/json" } } }, { "request": { "method": "GET", "url": "/api/orders/unavailable" }, "response": { "status": 503, "jsonBody": { "error": "SERVICE_UNAVAILABLE" } } } ]These examples configure three distinct scenarios:
/api/orders/500: HTTP 500 Internal Server Error./api/orders/slow: HTTP 200 after a three-second delay./api/orders/unavailable: HTTP 503 Service Unavailable.
Save the mappings in your WireMock
mappingsdirectory or register them using its admin API. Point your application's test configuration at the mock server instead of the real dependency.3. Build a resilience test matrix
Start with a defined set of failure scenarios so you can reproduce failures and verify the expected behavior.
Scenario Mock behavior What to verify Server error HTTP 500 Retry policy and error handling Rate limiting HTTP 429 Backoff and Retry-AfterhandlingDependency unavailable HTTP 503 Fallback behavior Slow response 2–5 second delay Client timeouts and loading states Request timeout Delay exceeds client deadline Cancellation and graceful degradation Connection reset Terminate the connection Retry logic and connection recovery Intermittent failure Fail some requests, succeed others Recovery after retries Malformed response Invalid or truncated JSON Validation and safe error handling WireMock supports fixed and randomized delays as well as several connection and malformed-response faults. For actual network timeouts and connection disruptions, Toxiproxy is another useful option.
4. Test realistic response-time distributions
A fixed delay is useful for deterministic tests, but production systems often experience variable latency.
Consider testing these profiles:
Normal latency
50–150 ms with small amounts of jitter. Establish baseline behavior.
Elevated latency
500–1,500 ms. Verify deadlines, responsiveness, and retry budgets.
Long-tail latency
Occasional 3–10 second responses. Verify timeouts, cancellation, and fallback paths.
These are example test values, not universal production thresholds. WireMock supports uniform and log-normal delay distributions for introducing jitter and long-tail latency.
5. Automate the tests in your CI pipeline
A useful test loop looks like this:
1. Start mock server
Load endpoint mappings and fault scenarios
2. Inject a failure
500, 503, latency, timeout, or connection reset
3. Execute application tests
Assert retries, fallback responses, and recovery
4. Collect results and clean up
Check error rates, latency, logs, and leaked resources
A few important practices:
- Make failure scenarios deterministic for ordinary CI tests; use randomized chaos experiments separately.
- Test that retries have limits and exponential backoff, so failures do not amplify load.
- Check that circuit breakers open during sustained failures and recover afterward.
- Set explicit timeouts and a total retry budget.
- Keep fault injection confined to test environments, and reset mock state between tests.
6. Tailor the setup to your stack
I can provide a working example with the mock configuration, test code, and commands to run it. Which environment are you using?
Your application stack
Node.js / Jest
Python / pytest
Java / Spring Boot
.NET / xUnit
Go
Other
Which failure modes do you need?
What are you testing?
An HTTP API or microservice
A frontend consuming an API
A database or external dependency
[Generate my test setup]
Sources cited in this answer9
- wiremock.orgSimulating Faults | WireMock
- wiremock.orgStubbing | WireMock
- mock-server.comChaos Testing & Fault Injection | MockServer
- github.comGitHub - Shopify/toxiproxy: :alarm_clock: A TCP proxy to simulate network and system conditions for chaos and resiliency testing · GitHub
- wiremock.orgSimulating Faults | WireMock
- github.comGitHub - Shopify/toxiproxy: :alarm_clock: :fire: A TCP proxy to simulate network and system conditions for chaos and resiliency testing
Google AI ModeOct 5, 2026
To thoroughly validate your application's failure handling, timeouts, and resilience, you need an API mocking tool that supports fault injection (latency, random/deterministic HTTP errors, and connection drops).
Here are the top tools that handle configurable network lag and error states exceptionally well, categorized by how you intend to run them:
1. Mockoon (Open Source / Desktop)
- Overview: A fantastic, lightweight desktop application (and CLI) that lets you quickly spin up mock APIs with a visual UI.
- Lag & Error Features: You can configure a global or route-specific delay (in milliseconds) for network lag. You can also specify response status codes (e.g., 500, 503, 404) and define rules to trigger errors conditionally based on headers, query params, or body content.
- Get started: Download or explore documentation on the Mockoon Official Website.
2. MockServer (Open Source / Self-Hosted & Docker)
- Overview: A robust, developer-focused tool built specifically for robust integration testing, unit testing, and chaos engineering.
- Lag & Error Features: Offers advanced Chaos Testing profiles. You can configure probabilistic or deterministic fault injection—including artificial latency (delays), explicit HTTP error statuses (500, 429, etc.), and hard TCP connection drops to test connection resets. It can act as a local mock server or a proxy sitting in front of real upstream dependencies.
- Get started: Check out the setup guides on MockServer Docs.
3. WireMock (Open Source / Cloud / Java or Standalone)
- Overview: The industry gold standard for mocking in JVM environments, available as a standalone binary, Docker container, or managed cloud service.
- Lag & Error Features: WireMock allows fine-grained response tuning. You can set fixed or random uniform/log-normal delays (
"fixedDelayMilliseconds": 2000) and return fault responses like empty responses, garbled bytes, or connection interruptions alongside standard HTTP error codes. - Get started: Explore configuration options at WireMock.org.
4. Beeceptor (Cloud / SaaS)
- Overview: A hosted, easy-to-use mocking solution that requires zero local installation.
- Lag & Error Features: Allows you to define custom rules where you can inject response latency (delaying the response by a set number of seconds) and force specific HTTP status codes or custom payloads on the fly.
- Get started: Test it out directly via Beeceptor.
To help narrow down the best fit, tell me:
- Do you prefer a local desktop app/GUI (like Mockoon), a code/Docker-based tool (like WireMock or MockServer), or a cloud-hosted mock (like Beeceptor)?
- Are you planning to run these tests locally on your machine or inside a CI/CD pipeline?
ChatGPT SearchOct 5, 2026
WireMock is probably the strongest fit. It supports configurable fixed/random latency, HTTP error responses, connection resets, malformed responses, and slow/chunked responses—excellent for resilience and timeout testing.
Other good options:
- Mockoon — very approachable GUI; supports simulated latency plus multiple/rule-driven responses and error status codes.
- Mockzilla — specifically offers configurable latency and per-service/endpoint error rates.
- WireMock Cloud — useful if you want shared/team simulations and configurable failure/latency scenarios without managing infrastructure.
My pick: WireMock for automated integration tests; Mockoon for quickly experimenting locally. WireMock docs Mockoon
Sources cited in this answer6
- wiremock.orgSimulating Faults | WireMock
- mockoon.comMockoon complete list of features
- mockzilla.orgSimulate Latency and Errors on a Mock API | Mockzilla
- wiremock.ioAPI mocking and simulation tools in WireMock Cloud
- wiremock.orgWireMock Java - API Mocking for Java and JVM | WireMock
- mockoon.comCreate mock APIs in seconds with Mockoon
ChatGPT SearchOct 2, 2026
WireMock is the strongest fit for highly realistic API simulation. It supports fixed and randomized latency, long-tail latency distributions, chunked responses, HTTP errors, connection faults, stateful behavior, record/playback, and dynamic responses.
Service Latency simulation Error/fault simulation Realism WireMock / WireMock Cloud Excellent Excellent Excellent Mockoon Excellent Good Excellent Mountebank Good Excellent Very good MSW Code-driven Code-driven Good For example, WireMock can model a log-normal latency distribution rather than simply sleeping for a fixed number of milliseconds—useful for reproducing realistic long-tail network behavior.
WireMock is my recommendation if realistic failure/latency behavior is the primary requirement.
Sources cited in this answer2
Google AI ModeOct 2, 2026
When looking for the best, most realistic API mocking capabilities—specifically for advanced network condition simulation like latency and deep error state injection—the developer community generally points to a few top contenders depending on whether you need a local development mock, a standalone server, or
enterprise service virtualization.- WireMock / WireMock Cloud : Widely considered the gold standard for robust API simulation. It goes far beyond simple status code returns by supporting fixed, random, and chunked delays, bandwidth throttling, and advanced fault injection (such as dropping connections midway, sending garbage data, or resetting sockets). It supports stateful behavior and dynamic response templating via Handlebars.
- Mockoon : The best open-source desktop application for quick, highly visual mock API creation. It makes adding granular per-route or global latency, random response times, and specific HTTP error codes (like 500, 503, or custom payloads) remarkably frictionless without writing configuration files.
- MSW (Mock Service Worker) : If your definition of "realistic" means intercepting requests at the network level inside the browser or Node.js test environment (without spinning up an external server), MSW is unmatched for frontend development. It allows you to use standard
async/awaitdelays (ctx.delay()) and standard network error throws right inside your service worker layer. - Postman Mock Servers : Excellent for teams already embedded in the Postman ecosystem. It allows you to generate mock endpoints straight from a collection or OpenAPI spec with basic configurable delays, though it is less granular for chaotic network faults or advanced stateful scripting compared to WireMock.
To help narrow down the ideal tool for your stack, let me know:
- Are you mocking APIs for frontend development (browser/SPA), backend integration testing , or an E2E automated pipeline?
- Do you prefer a local UI/desktop app , an in-code library , or a hosted cloud service?
Also asked as
- What's a good API mocking tool that can generate realistic data and simulate network latency?