#
Implementation Guide
To implement a pre-run script in Kusho:
- Navigate to the Collections section in the sidebar.
- Select the desired collection or folder where you want to add your script.
- Open the Scripts tab and select the Pre-run sub-tab.
- Enter your JavaScript code in the provided editor.
- 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');