Speed up your application development with Mockoon

Nabin Shrestha
4 min readJul 3, 2022

We’ve all went through the painful moment where we have to fix something in our application. You may not be able to directly test the issue in production server so you run your application in dev server. But the dev server might be down or behind the production server. Also, you have to ask for test login credentials which will cause too much delay which will make you bored and uninterested to fix the bug.

Waiting for dev server to work properly.

What if there was a way to run a local server in your PC and directly get to fixing the bug. Well, there is. Mockoon to the rescue. Mockoon is the easiest and quickest way to run mock REST API servers. No remote deployment, no account required, free, open source and cross-platform.

Mockoon

Now, after you’ve installed this all you’ve gotta do it setup an environment which mimics your server by adding required endpoints and possible responses. You might feel like it’s a hectic job but once you’ve set this your development will be so smooth and easy. So let’s get to it.

Open Mockoon application and create a new environment.

Creating a new environment

Save it in a preferred location.

Saving mock server

Select the settings tab and check on which port the server is going to run. For me it’s showing 3000.

Now let’s add a response which will be shown when we’ll enter the http://localhost:3000 in browser.

Mock Response on root

After this, click the play button and open http://localhost:3000 in your browser. It will show something like this:

Mock server is running.

That’s it. Now let’s create demo restful api for login. We are going to return a JSON response. For instance on successful login, server might return us with a message with status code 200 that login was successful.

Login API

Login is a POST request as we have to send username and password so we wont’t get anything when we enter http://localhost:3000/login in browser. So, let’s test it using Postman.

Testing Login API using Postman

Here, we see that we get the response we wrote in Mockoon. We get the status 200 OK. We might want to test failure case also. We can add failure responses in Mockoon and set it as the response. Let’s do it also.

Adding various types of responses

Click on + sign. You’ll be presented with list of status codes. Choose a status code of your preference and add appropriate response.

Choose from status codes
Making response default

After adding response make the response default by clicking on the pointed icon.

Now let’s make request via Postman and we’ll get:

Error response in login API

That’s it folks. This is how we can use Mockoon to mock Restful APIs and speed up our application development and reduce our dependency on dev server. Don’t forget to clap this article if you liked it.

🎉 Happy Coding!!! 🎉

--

--