> ## Documentation Index
> Fetch the complete documentation index at: https://collabase.ch/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Collabase documentation. Interface labels are quoted in English, as they appear in the product.
> Features marked Enterprise need the Collabase Enterprise Edition licence.

# Test a plug

> Check a plug before people rely on it: unit tests for your logic, an upload to a test instance, a step test with real data and a read of the run log.

A plug is code that calls a system you do not control. Test it in layers, from your own code to a real run.

## 1. Test your own logic

Write the work of an action as plain functions, such as `listOrders(token, query)`, and keep the action thin. Test the functions with any test runner against recorded answers of the other system. You then do not need Collabase to know that a date is parsed or a page is requested correctly.

## 2. Build and check

```bash theme={"dark"}
collabase-plug build
```

A successful build means the plug bundles into one file and that every dependency has an allowed licence.

## 3. Upload to a test instance

Upload to an instance that is not your production one, with an API token of an administrator there. Give each test upload a new version. See [Publish and versions](https://collabase.ch/docs/developer/plugs/publish.md).

## 4. Test a step with real data

**1. Create a flow**

In a test workspace, create a flow and add a step of your plug.

**2. Create a connection**

If the plug needs credentials, create a connection with a test account of the other system.

**3. Test the step**

Fill in the inputs and select **Test step**. The step runs once in the sandbox, for real. The result is shown and saved, and the data picker of later steps offers its fields.

## 5. Read the run

Run the flow and open it under **Runs**. Check the input of the step as the plug received it, the output, and the message of a failed step. A secret never appears in the log: Collabase replaces the values of the connection with `***`. See [Debugging runs](https://collabase.ch/docs/automation/debugging-runs.md).

## What to try

| Case | Why |
| - | - |
| A required input left empty | The editor stops this, but a reference that resolves to nothing reaches the plug. |
| The other system answers with an error or does not answer | The message of the failed step must say what to do. |
| A connection with a wrong key | The step must fail with a clear message and never show the key. |
| The same step twice | Repeats must not create a second order. |
| A large result | The result must stay small, or a file must carry the content. |

Webhook triggers cannot be tested before the flow is published, because the other system sends the data. See [Webhook trigger](https://collabase.ch/docs/developer/plugs/webhook-trigger.md).

## Related

* [Publish and versions](https://collabase.ch/docs/developer/plugs/publish.md)
* [Debugging runs](https://collabase.ch/docs/automation/debugging-runs.md)
* [Actions](https://collabase.ch/docs/developer/plugs/actions.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.