Introduction

docs.telerik.com: Fiddler's AutoResponder allows you to return files from your local disk instead of transmitting the request to the server.

You can mock response for any request with Fiddler AutoResponder. Let's imagine, You are working in web development and you are dependent on another API, Like, Login service for your front end application, your API may depend on 3rd party service. You need to mock these services to test the negative scenarios.

Even you can mock HTML, CSS and JS files too.

Let's say you fixed a bug in your CSS or JS files in your local but you need to test it with production or staging server without any deployment. Because, deployment takes more time. So you can easily mock your production/staging CSS or JS files with your local files. Cool right.

Installing Fiddler

  1. Go to https://www.telerik.com/fiddler and download and install fiddler software.
  2. Open fiddler and go to Tools -> Options from the top menu bar. Fiddler tools options
  3. Popup window will appear in the screen. select HTTPS -> Actions -> Reset All Certificates. Fiddler https reset certificate
  4. Select OK and YES options for all upcoming the popups. Fiddler certificate installing
  5. Now, Fiddler is ready to mock any request.

Mocking Response

  1. Click on the AutoResponder tab in the right side pane.
  2. Select the Enable rules and Unmatched requests passthrough. Fiddler autoresponder tab
  3. Click Add rule button. Two inputs inside rule editor are enabled to configure.
  4. In the rule editor, there are two inputs that will be there.

    • First input need to provide the request URL. you can provide a regex pattern to match multiple request URLs or simply provide the Exact URL that needs to be mocked.
    • In another input, you can select files from your local by selecting Find File in the dropdown.
  5. After filling both input, click Save button. Fiddler autoresponder save
  6. Here I mocked a CSS file on w3schools website. You can mock any request like this for your development. Fiddler mocking response

API mocking

  1. In the rule editor, there are two inputs that will be there.

    • First input need to provide the request URL. you can provide a regex pattern to match multiple request URLs or simply provide the Exact URL that needs to be mocked.
    • In another input, you can create your response by selecting Create new response in the dropdown.
  2. After filling both input, click Save button. Fiddler mocking response
  3. A popup will be appear to create response.
  4. Select Raw tab and you can edit the headers, response code, response message whatever you want. Fiddler create response
  5. Click Save button and close the popup. Now you can verify the mocked response in your machine anywhere. Fiddler verify response
  6. Here I mocked a response for your understanding. Fiddler API response mock
  7. If you need to edit this response, right click and choose Edit response, then popup will appear, now you can modify the response. Fiddler verify response