Mocklets
Published in

Mocklets

Mock your APIs without any code change with Charles Proxy

Using Charles Proxy with Mocklets

If you have ever developed any front-end application whether web or mobile, its very likely you must have heard about Charles Proxy. But for those who haven’t, Charles is, as described on its site:

Now, in the last article, we learned about how Mocklets can be used to speed up the development process. But speed only doesn’t always suffice the needs of a better development process. We need a quality product too. This is where Mocklets comes to rescue, again.

Quality assurance is a critical part of application development. Mocklets empowers the quality testing by allowing testing of edges cases and inducing production environment which actual servers cannot reproduce reliably. But since quality testing will be taking place on your release candidate build, it is very late to keep making changes in your code to point API requests to Mocklets.

So how do we point some of our API requests to Mocklets, while keep pointing to actual server APIs, without making any code changes.

Proxying to Mocklets with Charles

Now that Charles Proxy is setup, it will start showing all the calls being made from our application.

Let’s take an example where our application is making a GET request to http://dummy.restapiexample.com/api/v1/employees which responds with the list of employees.

Response from server API

Now, let’s try to forward requests made to above API to Mocklets. For that we first need to create a mock API on Mocklets.

Now, we will map our API request, going to our server, to be forwarded to Mocklets API. (Right click on the specific request > Select “Map Remote”)

Once you see Edit Mapping dialog, provide the details required to forward the request and press OK.

And, that’s all, you are all done. From now onwards, all the requests you make to the specified API, those will be forwarded to Mocklets API and you will receive a mock response.

Response from Mocklets API

Isn’t it super easy!!!

Using Mocklets with Charles Proxy, gives you flexibility to send some requests to Mocklets, while keep pointing to actual server for rest, that too without making any changes in application code. This ability make Mocklets indispensable to application development process.

Try out Mocklets, and if you need more information about how to use this tools, visit their documentation page.

Happy coding!!!

--

--

Make better apps faster by mocking the APIs you depend on

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store