Creating a Mapping File

The Mapping file is a JSON file that includes an array of entries, which includes an array of requests and responses. Each request can be mapped multiple times to a single response. The JSON should have entries like the ones found in a HAR file. The following elements are mandatory:

  • URL in the request
  • Status in the response OR RedirectUrl
  • In case of NOT mapping a GET call, specify the method type as part of the request

For the URL you can use * as wildcards, which means any request that matches the pattern will be caught and mapped to the response in the file.
The mapping file should be saved locally.

Mapping file useful examples

Mapping file with a JSON object in response

{
  "entries": [
    {
      "request": {
        "url": "*/urlRequestYouWantToMock/*?=yourQueryParam"
      },
      "response": {
        "status": 200,
        "headers": [{
          "name": "Content-Type",
          "value": "application/json; charset=utf-8"
        }],
        "content": {
          "text": "{\"mock\": \"network\"}"
        }
      }
    }
  ]
}

Mapping file with a method specified (for non GET mappings)

{
  "entries": [
    {
      "request": {
        "method": "POST"
        "url": "*/urlRequestYouWantToMock/*?=yourQueryParam"
      },
      "response": {
        "status": 200,
        "headers": [{
          "name": "Content-Type",
          "value": "application/json; charset=utf-8"
        }],
        "content": {
          "text": "{\"mock\": \"network\"}"
        }
      }
    }
  ]
}

Mapping file with a redirectUrl in response

{
    "entries": [
      {
        "request": {
          "url": "*/urlRequestYouWantToMock/*?=yourQueryParam"
        },
        "response": {
            "redirectUrl" : "https://www.google.com"
          }
      }
    ]
  }

Mapping file with a text in the response

{
    "entries": [
      {
        "request": {
          "url": "*/urlRequestYouWantToMock/*?=yourQueryParam"
        },
        "response": {
            "status" : 200,
            "headers": [{
                "name": "Content-Type",
                "value": "text/html; charset=UTF-8"
              }],
              "content": {
                "text": "mock network"
              }
            
          }
      }
    ]
  }

Creating a mapping file that enables pass-through authentication for login

If your test includes a login process, which involves passing credentials to a server, it may not work properly when running the test on the mock network, as the login request will be timed out. To solve this issue, you should create a mapping file that includes the login request and the enabled Pass-through authentication property.

The following example enables the pass-through authentication for the login request:

{
"entries": [
    
      {
          "request": {
          "url": "https://your_app_domain/login/*"
        },
            "response": {
            "passthrough":true
        }
      }
    ]
}

Replace the URL with your login URL.

Uploading the Mapping File

To upload your mapping file:

  1. In the Test Properties pane, click Upload Custom Mapping File.
274274
  1. Locate the custom Mapping file that you saved and click Open to upload it.
  2. Click Save to save the activate.
435435