# Implementation Guide

To implement a pre-run script in Kusho:

  1. Navigate to the Collections section in the sidebar.
  2. Select the desired collection or folder where you want to add your script.
  3. Open the Scripts tab and select the Pre-run sub-tab.
  4. Enter your JavaScript code in the provided editor.
  5. Click the Save button to apply your changes.

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

// 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');