Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support separate Slack channels for notifications of successful and failed test results #82

Merged
merged 1 commit into from
Jan 11, 2024

Conversation

m-kusnierz
Copy link
Contributor

This PR adds support for sending Slack notification to different channels depending on the test results (passed or failed).

Resolves issue: #69

@@ -208,10 +217,20 @@ class SlackReporter implements Reporter {
};
}

if (!this.sendResults || this.slackChannels?.length === 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition was not true when this.slackChannels was undefined.
With a change to slightly stricter validation I had to update the test data here 👉 https://github.com/ryanrosello-og/playwright-slack-report/pull/82/files#diff-62ed587fd8e65d151c73c06fa1f2fd6d4e3c45760c124f1505f41fa1d547f8cdR295-R322

@ryanrosello-og
Copy link
Owner

I tested this just now, works good @m-kusnierz !
2024-01-11_19-38-28

And its backwards compatible too (using just plain old channels key)

@ryanrosello-og ryanrosello-og merged commit 7719f5d into ryanrosello-og:main Jan 11, 2024
1 of 2 checks passed
@RAZAW
Copy link

RAZAW commented Jan 25, 2024

Hey Ryan,
Also in a situation for sending messages to different channels. Just curious where your slackWebhookUrl or other alternatives are in the config?
Secondly, the slack incoming web hooks are specific to a single channel, so how does the channels array work? If you can advise on how to post to multiple channels that would be great.
Just for reference my use cases are:

  1. Send message to multiple channels
  2. Send message to channel based on test tag

@RAZAW
Copy link

RAZAW commented Jan 26, 2024

Managed to figure out the comment above by using slackoAuthToken property in TestConfig I can use the array of channels. I couldn't see it in your config file above may be you'd have set the env variable at runtime or script. Thanks anway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants