Testim Documentation

Welcome to the Testim documentation. You'll find comprehensive guides to help you get started quickly, example code snippets, and tips for being more productive. You will also find details about advanced features that allow you to customize Testim to fit your environment or special testing conditions. Don't worry, we'll support you if you get stuck. Let's jump right in!

Guides    Changelog

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

For the URL you can use * as wildcards, that 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 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.
  1. Locate the custom Mapping file that you saved and click Open to upload it.
  2. Click Save to save the activate.

Updated 7 months ago

Creating a Mapping File


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.