# Testing scripts

## **Introduction**

The script editor has an integrated testing panel, to the right of your code:&#x20;

<figure><img src="/files/Ex31DMMtEeZP8xclaHkl" alt=""><figcaption></figcaption></figure>

Here, you can enter a sample payload with (if needed by the script) sample variables and run the script in test mode.&#x20;

## **The steps**

Follow the steps below:

**Step 1**\
Move across to the `test` panel, to the right.

**Step 2**\
Add/paste a payload that can be used to test your script - for example:

<div align="left"><figure><img src="/files/fKPN0AjvQHSD9f1OjDdk" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 3**\
If your script references [variables](/product-documentation/process-flows/building-process-flows/dynamic-variables/payload-variables.md) or [flow variables](/product-documentation/process-flows/building-process-flows/dynamic-variables/flow-variables.md), you can also add variables for testing:

<div align="left"><figure><img src="/files/fKPN0AjvQHSD9f1OjDdk" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 4**\
Click the `run` button:

<div align="left"><figure><img src="/files/aKFGN5meTZe3KH224uja" alt="" width="303"><figcaption></figcaption></figure></div>

...the script runs against your test payload and results are displayed at the end - for example:

<div align="left"><figure><img src="/files/Ia8dBcRqEubPOhb42nlh" alt="" width="303"><figcaption></figcaption></figure></div>

{% hint style="info" %}
For more detailed information about a script test, you can `get logs`:

![](/files/Uc2qUP1PaOR1NbOunDmP)\
\
...current logs are displayed:

![](/files/z5D4cNSU2PFfIgUBAASC)
{% endhint %}

**Step 5**\
Keep testing the script until you're satisfied that it's working as required.&#x20;

{% hint style="warning" %}
Any time that you make a change to the script and want to test it, always `save and deploy` the code first. When you run a script, it always uses the last saved version.
{% endhint %}

Once these tests are complete, you can:

* [Apply a payload-level script to process flows via the script shape](/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/script-shape.md)&#x20;
* [Apply a field-level custom script to field transformations via the map shape](/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/map-shape.md)&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.wearepatchworks.com/product-documentation/developer-hub/custom-scripting/creating-and-testing-custom-scripts/testing-scripts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
