TestOps Script
This code defines functions called runSmoke() , runRegressions() and runSingle that executes a series of asynchronous tasks related to running a smoke test. Here is the updated documentation for each part of the code:
- smoke(), regression() and runSingle()
- Description: Smoke and regression tests are used to set the current object for testing behavior and provide the path where all test cases are located. On the other hand, the 'runSingle' function only provides a path to a single JS file.
- Return value: The current script object.
- run(options = )
- Description: Executes the smoke test by running Cypress tests.
- Parameters:
options(optional): An object containing additional options for the test run.preferCache(boolean): If set totrue, the test results will be cached and not rerun.
- Return value: The current script object.
- postJira()
- Description: Posts the test results to Jira using XRay API.
- Return value: The current script object.
- postWebhooks()
- Description: Posts the test results to multiple Slack webhooks.
- Return value: The current script object.
- createSlackThread(body = this._.statsMessage)
- Description: Creates a new thread in Slack channel and posts the test statistics.
- Parameters:
body(optional): The message body to be sent as the initial message in the thread. Defaults to the statistics message generated by the script.
- Return value: The created Slack thread object.
- replyFailedList(parentThread, generator)
- Description: Generates a list of failed test cases and replies to the parent Slack thread with the failure details.
- Parameters:
parentThread: The parent Slack thread object to reply to.generator: A function that generates the Slack message blocks based on the failed test cases data.
- Return value: None.
Properties:
- this.xray
- Description: Contains XRay configuration details.
- Properties:
cloudUrl: The XRay cloud URL obtained from theconfig.xray.cloudUrlenvironment variable.authUrl: The XRay authentication URL obtained from theconfig.xray.authUrlenvironment variable.client: An object containing client details.id: The XRay client ID obtained from theconfig.xray.client.idenvironment variable.secret: The XRay client secret obtained from theconfig.xray.client.secretenvironment variable.
- this.slack
- Description: Contains Slack configuration details.
- Properties:
webhooks: An array of Slack webhook URLs obtained from theconfig.slack.webhooksenvironment variable.messageUrl: The Slack message URL obtained from theconfig.slack.messageUrlenvironment variable.accessToken: The Slack access token obtained from theconfig.slack.accessTokenenvironment variable.channelId: The Slack channel ID obtained from theconfig.slack.channelIdenvironment variable.
- this.jira
- Description: Contains Jira configuration details.
- Properties:
ticket: The Jira ticket obtained from theconfig.jira.ticketenvironment variable.
- this.cypress
- Description: Contains Cypress configuration details.
- Properties:
resultsDir: The directory path for Cypress test results obtained from theconfig.cypress.resultsDirenvironment variable.browser: The browser configuration for Cypress obtained from theconfig.cypress.browserenvironment variable.specs: An object containing test specification paths for different sets of tests.smoke: The path to the smoke
test specifications obtained from the config.cypress.specs.smoke environment variable.
regression: The path to the regression test specifications obtained from theconfig.cypress.specs.regressionenvironment variable.
- this._
- Description: Contains internal properties used by the script.
- Properties:
specs: The current test specifications, initially set as an empty string.statsMessage: The statistics message, initially set as an empty string.jiraTicketUpdated: An object representing the updated Jira ticket information, initially set as an empty object.testSet: The current test set, initially set as "Smoke".cypressResult: An object representing the result of the Cypress test run, initially set as an empty object.testFilesPath: The absolute path to the directory for test files within the Cypress results directory, obtained by combining the Cypress results directory path with "files".resutlsFile: The absolute path to the test results file within the Cypress results directory, obtained by combining the Cypress results directory path with "test-results-all.xml".
Please ensure that the config object is properly defined and contains the necessary environment variables for each configuration property mentioned above.