#
Implementation Guide
To implement a pre-run script in Kusho:
- Go to the Test Suites section in the sidebar.
- Select the desired test suite where you want to add your script.
- Click on the Pre Run Script button located at the top of the Test Suites section, to the left side of the search bar.
- A drawer will open.
- Write your JavaScript code in the top section of the code editor within the drawer.
- Click Run to see the results at the bottom of the drawer.
- Click the Save Script 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');