# Implementation Guide

To implement a pre-run script in Kusho:

1. Go to the **Test Suites** section in the sidebar.
2. Select the desired test suite where you want to add your script.
3. Click on the **Pre Run Script** button located at the top of the Test Suites section, to the left side of the search bar.

![](pre-run-btn.png)

4. A drawer will open.
5. Write your JavaScript code in the top section of the code editor within the drawer.
6. Click **Run** to see the results at the bottom of the drawer.
7. Click the **Save Script** button to apply your changes.

![](pre-run-script.png)

Here's a basic example of a pre-run script:

```javascript
// Generate a unique identifier for the test run
const uniqueId = Date.now().toString(36) + Math.random().toString(36).substr(2);
setVariables({ testRunId: uniqueId });

// Log the generated ID
debug(`Generated unique test run ID: ${uniqueId}`);

// Set up global variables for the test run
const globalVars = {
    'baseUrl': 'https://api.kusho.com',
    'testEnvironment': 'staging'
};

// Update the variables
setVariables(globalVars);

debug('Pre-run script completed successfully');
```
