morooLee / wdio-slack-reporter

This reporter provides slack notifications of WebdriverIO test results.
11 stars 6 forks source link

Possibility to filter detailed results. #24

Closed lamkovod closed 2 years ago

lamkovod commented 2 years ago

It would be great to have feature to choose / filter tests for detailed message in thread. The most common and easy way to implement this will be filtering by results.

Configuration example:

                slackOptions: {
                    type: 'web-api',
                    slackBotToken: 'xoxb-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
                    channel: 'XXXXXXXX',
                    notifyDetailResultThread: 'failed',
                    uploadScreenshotOfFailedCase: true,
                },

notifyDetailResultThread options : 'all' / 'failed' / 'passed'

morooLee commented 2 years ago

Hello @lamkovod I will reflect your suggestions as soon as possible. Thank you!

morooLee commented 2 years ago

Hello @lamkovod I did not know how to use github well, so I modified it after merging.

// wdio.conf.js
export.config = {
  reporters: [
    [
      SlackReporter, {
        // Set the Slack Options used web-api.
        slackOptions: {
          type: 'web-api',
          slackBotToken: process.env.SLACK_BOT_TOKEN || "xoxb-xxxxxxxxxx-xxxxxx...",,
          channel: process.env.SLACK_CHANNEL || "Cxxxxxxxxxx",
          // Set this option to true to attach a screenshot to the failed case.
          uploadScreenshotOfFailedCase: true,
          // Set this option to true if you want to add thread with details of results to notification of test results posted to Slack.
          notifyDetailResultThread: true,
          // Set the Filter for detail results. (array is empty or undefined, all filters are applied.)
          filterForDetailResults: [
            'passed',
            'failed',
            'pending',
            'skipped'
          ],
        },
      }
    ],
  ],
};

Document

notifyDetailResultThread (Optional)

This option only works when the notifyTestFinishMessage option is true.

Set this option to true if you want to add thread with details of results to notification of test results posted to Slack.

  • Scope: web-api
  • Type: boolean
  • Default: true

filterForDetailResults (Optional)

This option only works when the notifyDetailResultThread option is true.

Add the filter you want to this option to the array and the detailed results will be filtered out in Slack and sent to the thread. (If there are no filters (array is empty or undefined, all filters are applied.) Filter list: passed, failed, pending, skipped

  • Scope: web-api
  • Type: array (passed | failed | pending | skipped)
  • Default: ['passed', 'failed', 'pending', 'skipped']