We review using Mockoon to create API mocks quickly

APIs are complex. By their very nature, APIs facilitate complex interactions that are necessarily more in whole than the sum of their parts. Unfortunately, this also means that it’s often difficult to know how an API will function before it goes into the wild.

Enter the concept of mocking. Mocking helps test arguments, validate approaches and more to ensure that a solution works. An API mock is, thus, a simulation of an API in practice in a limited form. For APIs, mocking can take a variety of shapes, like virtualization, sandboxing, or HTTP request mocking.

Below, we review another way to mock APIs using the open-source tool, Mockoon. We’ll look at what Mockoon is, what it does, and how it might add value to your development cycle.

What is Mockoon?

You can download Mockoon here or check it out on GitHub.

One of the most important routines an API developer can adopt is continuous testing. The ability to mock your API and its requests and compare their actual output with their designed output is critical to a successful API product. However, equally important to testing is the quality of testing — test results are only as good as the condition and process that generated them.

As such, finding a low-cost option for mocking and testing is paramount to success. There’s a problem in this, however, as how you mock reflects in the results. If you hardcode and test, you’re creating code bloat at best and making your source of truth convoluted at worst. Online mocking solutions can be a solution, but you introduce a certain amount of “fog” to the process, depending on the latency, service metrics, and general appliance of the online resources, not just your code.

Mockoon was created to offer a solution to mock testing that is free, open-source, and, most importantly, local. By limiting the mock testing to a local instance, the code is tested in a consistent environment free of external influence. While the testing may still be affected by local resource restrictions, processing speeds, etc., you can still test mocks in a one-to-one fashion, eliminating outside influence.

What Can Mockoon Do?

Mockoon boasts an impressive roster of features. In addition to allowing an unlimited number of mock APIs with an unlimited number of routes, Mockoon also allows for various environments, ranging from GitHub to Docker and everything in between. Docker allows for relatively robust importing and exporting and regex-based routes based on the ExpressJS syntax. All in all, Mockoon offers various features to make mock testing easier, more efficient, and more resource-friendly.

Mockoon Features

The following is a complete list of features from the Mockoon documentation, along with commentary for how each feature provides better results:

  • Unlimited mocking – Create an unlimited number of mock APIs with unlimited number of routes and run them in parallel.

API mocking is often not a binary between one API working and one API not. The modern API space often requires many interlocking parts, as well as data served between APIs. The ability to create multiple mocks and have them run both with multiple routes and in parallel tests this common use case. This allows developers to test real-world conditions for a networked API at a much higher level than might otherwise be possible.

  • Run your mock anywhere – Use the CLI to run your mock APIs in any headless or automated environment: CI, GitHub Actions, Docker containers, etc.
  • Docker support for the CLI – Run the CLI directly as an NPM package or use the provided Docker image.

The ability to run the mock for your API is critical. The environment in which APIs are developed and deployed is as vast and varied as ever, and as such, having a solution that supports multiple environments is critical to success. Additionally, Mockoon supports a wide range of mock implementations to widen its support breadth, meaning that the particular approach chosen by a developer is not an additional wall to the application — for open-source software, this is critical.

  • Import / export – Mock API import / export with Swagger/OpenAPI format support.
  • Route regex – Route regex supported (/.*, /[a-z]{3}, …), based on ExpressJS syntax.
    Multiple responses per route – Serve multiple rules-triggered or random responses with any headers body, or HTTP status codes.
  • CORS – Automatically send CORS headers (Access-Control-Allow-Origin, etc.) for OPTIONS requests.

Mockoon offers some advanced features which, in tandem, provide valuable avenues for experimentation and testing. The ability to import and export, especially utilizing OpenAPI, allows for rapid testing and development and quick iteration between different versions.

Additional support for route regex and CORS means that complex simulated interactions can be built rapidly, testing both basic interactions and more complex, detailed interactions that may touch multiple APIs, endpoints, or resources in a single circuit. This is very much a Swiss Army Knife sort of situation, and Mockoon succeeds in balancing sufficient support for its feature set.

  • HTTPS – Serve your mock API over TLS with self-signed certificate.

Creating a local server and serving this mock API over TLS adds security to testing and mimics your API’s route when utilizing HTTPS. This is important, as it will adequately reflect the most likely environment your API will function under.

  • Response headers – Add any response headers to your routes and mock API. With auto-completion.

This is another quality of life improvement, as the support for custom headers and auto-completion allows for more dynamic routes to surface data and context for their interactions.

  • Latency – Add latency at environment or route level or even both.

This may seem simple, but it’s actually one of the most important parts of testing web APIs. The reality is that latency is often the chief driving component for failure that is unrelated to code. When latency is introduced into the system, APIs can fail, and without proper error handling, you can’t really model what those interactions result in. Latency can also be somewhat random — your latency may be low during development, with subtle spikes during certain conditions. How do you simulate these random spikes in latency for testing? You mock using added latency.

  • Requests and responses logs – All incoming requests and outgoing responses are logged for easier debugging.

This is a relatively simple quality of life improvement – by logging all requests and responses, debugging is made simpler, and complex routes can be retraced and understood in comparison to one another more fully.

  • Proxy mode – Redirect all non-defined routes to the specified host with Mockoon’s proxy mode.

Proxies are an underappreciated facet of mocking, but let’s be clear – proxy redirects are perhaps the best tool for simulating network bottlenecks, failures, environment changes, authentication schemes, and just about anything that would alter the flow of data within a network. The ability to redirect traffic to proxied hosts is powerful for mocking.

  • File serving – File serving with automatic mime type detection and templating support.
  • Rich text editor – Rich text editor for body content supporting multiple languages (JSON, HTML, etc).

Providing full support for both complex media types and then allowing for rich text manipulation within a variety of languages allows for more complex interactions on media and API content than would otherwise be possible. This is increasingly important in the modern API space, so allowing this is paramount to experimentation and mocking.

  • Templating – Templating supported in body, file content and header, with many helpers: url params, query params, JSON body lookup, etc.

Templating is another powerful approach to mocking. Templates allow for standardization, which both delivers better results in code development as well as more cohesive and consistent testing across different environments and paradigms. Effective templating can standardize every level of the API and the API output itself, leading to better development, more effective testing, and, ultimately, better user experience.

  • Auto-save – Real-time auto save as you type. Never worry again about saving!

Another quality of life improvement – who wants to lose all of their work because they didn’t frantically and continually save their work?

  • Offline – No account, no sign-up, no cloud deployment required.

Simple but succinct. The ability to mock offline and without deploying to the cloud or signing up for an account is a breath of fresh air in a development sphere saturated with cloud SaaS.


Mockoon is one of those tools that’s really simple, and does that one thing really well, making it another contender for the API developer toolkit. Being able to test across various conditions, simulating the complex interactions between multiple different APIs and their complex routes and parallel processing dynamics, will ultimately lead to a better API, and thus, a better user experience.

What do you think of Mockoon? Are there any similar solutions that we should do an overview on? Let us know in the comments below!