> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# TestAutomation

# Package: triggers

# Namespace: EsbConfigResolver

# Method link: https://dev.wix.com/docs/api-reference/business-management/automations/triggers/triggered-events/test-automation.md

## Permission Scopes:
Set Up Automations: SCOPE.CRM.SETUP-AUTOMATIONS

## Introduction

Runs an automation in test mode, without reporting an event.


Test mode runs the automation and its actions for real, but it can also run unpublished draft automations and skips any configured delays so you see the results immediately. Use it to verify an automation's behavior before publishing it.

Identify the automation to run the same way as in [Run Automation](https://dev.wix.com/docs/api-reference/business-management/automations/triggers/triggered-events/run-automation.md).

---

## REST API

### Schema

```
 Method: testAutomation
 Description: Runs an automation in test mode, without reporting an event.   Test mode runs the automation and its actions for real, but it can also run unpublished draft automations and skips any configured delays so you see the results immediately. Use it to verify an automation's behavior before publishing it.  Identify the automation to run the same way as in [Run Automation](https://dev.wix.com/docs/api-reference/business-management/automations/triggers/triggered-events/run-automation.md).
 URL: https://www.wixapis.com/automations/v1/events/test-automation
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  identifierType, payload
 Method parameters: 
    - ONE-OF: 
     - name: preinstalledIdentifier | type: PreinstalledIdentifier | description: Identifies a preinstalled automation by its app GUID and component GUID.  
        - name: appId | type: string | description: GUID of the app that the preinstalled automation belongs to.  | validation: format GUID
        - name: componentId | type: string | description: GUID of the app component that defines the preinstalled automation.  | validation: format GUID
     - name: automationIdentifier | type: AutomationIdentifier | description: Identifies an automation by its GUID.  
        - name: automationId | type: string | description: GUID of the automation to run.  | validation: format GUID
   param name: identifierType | type: IdentifierType | description: Specifies how an automation is identified when calling Run Automation or Test Automation. | required: true 
      - enum:
           PREINSTALLED - Identifies a preinstalled automation by its app ID and component ID.
           AUTOMATION - Identifies an automation by its ID.
   param name: payload | type: payload | description: Event payload, formatted as key:value pairs. Must comply with the payload schema if you provided one when configuring your trigger.  Key names can include only alphanumeric characters or underscores (`A-Z`, `a-z`, `0-9`, `_`). They cannot start with an underscore.  Values can be strings, numbers, integers, booleans, or arrays. If a value is an array, the array items must be objects, and nested object properties must be strings, numbers, integers, or booleans only. | required: true 
 Return type: TestAutomationResponse
  - name: activationId | type: string | description: GUID of the activation created for this test run.  | validation: format GUID


```

### Examples

### TestAutomation
```curl
~~~cURL
curl POST https://www.wixapis.com/automations/v1/events/test-automation  \
  -H 'Content-Type: application/json;charset=UTF-8' \
  -H 'Authorization: <AUTH>' \
  -d '{
    "identifierType": "AUTOMATION",
    "automationIdentifier": {
      "automationId": "d7a341c4-196b-46e7-813c-2b0fc1847ec6"
    },
    "payload": {
      "customerName": "John Doe",
      "bookingId": "a1b2c3d4-5e6f-4a1b-9c8d-7e6f5a4b3c2d"
    }
  }'
~~~
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.automations.activations.testAutomation(identifierType, options)
 Description: Runs an automation in test mode, without reporting an event.   Test mode runs the automation and its actions for real, but it can also run unpublished draft automations and skips any configured delays so you see the results immediately. Use it to verify an automation's behavior before publishing it.  Identify the automation to run the same way as in [Run Automation](https://dev.wix.com/docs/api-reference/business-management/automations/triggers/triggered-events/run-automation.md).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  identifierType, options.payload, options
 Method parameters: 
   param name: identifierType | type: IdentifierType | description: Specifies how an automation is identified when calling Run Automation or Test Automation. | required: true 
      - enum:
           PREINSTALLED - Identifies a preinstalled automation by its app ID and component ID.
           AUTOMATION - Identifies an automation by its ID.
   param name: options | type: TestAutomationOptions  none | required: true 
    - ONE-OF: - required: true
     - name: preinstalledIdentifier | type: PreinstalledIdentifier | description: Identifies a preinstalled automation by its app GUID and component GUID.  
        - name: appId | type: string | description: GUID of the app that the preinstalled automation belongs to.  | validation: format GUID
        - name: componentId | type: string | description: GUID of the app component that defines the preinstalled automation.  | validation: format GUID
     - name: automationIdentifier | type: AutomationIdentifier | description: Identifies an automation by its GUID.  
        - name: automationId | type: string | description: GUID of the automation to run.  | validation: format GUID
        - name: payload | type: object | description: Event payload, formatted as key:value pairs. Must comply with the payload schema if you provided one when configuring your trigger.  Key names can include only alphanumeric characters or underscores (`A-Z`, `a-z`, `0-9`, `_`). They cannot start with an underscore.  Values can be strings, numbers, integers, booleans, or arrays. If a value is an array, the array items must be objects, and nested object properties must be strings, numbers, integers, or booleans only. | required: true 
 Return type: PROMISE<TestAutomationResponse>
  - name: activationId | type: string | description: GUID of the activation created for this test run.  | validation: format GUID


```

### Examples

### testAutomation
```javascript
import { activations } from '@wix/automations';

async function testAutomation(identifierType,options) {
  const response = await activations.testAutomation(identifierType,options);
};
```

### testAutomation (with elevated permissions)
```javascript
import { activations } from '@wix/automations';
import { auth } from '@wix/essentials';

async function myTestAutomationMethod(identifierType,options) {
  const elevatedTestAutomation = auth.elevate(activations.testAutomation);
  const response = await elevatedTestAutomation(identifierType,options);
}
```

### testAutomation (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { activations } from '@wix/automations';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { activations },
  // Include the auth strategy and host as relevant
});


async function testAutomation(identifierType,options) {
  const response = await myWixClient.activations.testAutomation(identifierType,options);
};
```

---