TestOps Script

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:

  1. 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.
  2. 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 to true, the test results will be cached and not rerun.
    • Return value: The current script object.
  3. postJira()
    • Description: Posts the test results to Jira using XRay API.
    • Return value: The current script object.
  4. postWebhooks()
    • Description: Posts the test results to multiple Slack webhooks.
    • Return value: The current script object.
  5. 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.
  6. 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:

  1. this.xray
    • Description: Contains XRay configuration details.
    • Properties:
      • cloudUrl: The XRay cloud URL obtained from the config.xray.cloudUrl environment variable.
      • authUrl: The XRay authentication URL obtained from the config.xray.authUrl environment variable.
      • client: An object containing client details.
        • id: The XRay client ID obtained from the config.xray.client.id environment variable.
        • secret: The XRay client secret obtained from the config.xray.client.secret environment variable.
  2. this.slack
    • Description: Contains Slack configuration details.
    • Properties:
      • webhooks: An array of Slack webhook URLs obtained from the config.slack.webhooks environment variable.
      • messageUrl: The Slack message URL obtained from the config.slack.messageUrl environment variable.
      • accessToken: The Slack access token obtained from the config.slack.accessToken environment variable.
      • channelId: The Slack channel ID obtained from the config.slack.channelId environment variable.
  3. this.jira
    • Description: Contains Jira configuration details.
    • Properties:
      • ticket: The Jira ticket obtained from the config.jira.ticket environment variable.
  4. this.cypress
    • Description: Contains Cypress configuration details.
    • Properties:
      • resultsDir: The directory path for Cypress test results obtained from the config.cypress.resultsDir environment variable.
      • browser: The browser configuration for Cypress obtained from the config.cypress.browser environment 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 the config.cypress.specs.regression environment variable.
  1. 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.