When you work in a team that uses Microsoft Teams as its primary communication tool, it can be useful to report your test results directly to a Teams channel. This way, everyone on your team can quickly see the test results and act on them if needed.
In this article, I will show you how you can report your Playwright test results to a Microsoft Teams channel.
Prerequisites
Before you can start reporting your Playwright test results to Microsoft Teams, you need to have the following:
- A Playwright project
- A Microsoft Teams webhook URL
- The playwright-msteams-reporter dependency
Create an incoming webhook for Microsoft Teams channel (will stop working after October 1, 2024)
importantAs Microsoft announce the retirement of Office 365 connectors within Microsoft Teams. It is best to make use of the Power Automate webhook functionality.
The playwright-msteams-reporter
dependency uses the incoming webhook feature in Microsoft Teams. You can find more information on how to do this in the Microsoft documentation.
Once you have configured the incoming webhook, you will receive a URL that you can use to send messages to a specific channel. Copy this URL, as you will need it in the reporter’s configuration.
Create a Microsoft Teams webhook with Power Automate
To create a webhook with Power Automate, you can follow these steps:
- Start with the following post to a channel when a webhook request is received template
- Click continue to use the template
- Click on the Post your own adaptive card as the Flow bot to a channel action
- Configure the action with the following settings:
- Team: Select the team where you want to post the message
- Channel: Select the channel where you want to post the message
- Click on the Save button
- Click on When a Teams webhook request is received and copy the HTTP URL
Installing the reporter
To install the playwright-msteams-reporter
dependency, run the following command in your Playwright project:
|
|
Configuring the reporter
Once you installed the reporter, it is time to configure it. In your playwright.config.js
configuration file, you can add the following configuration to enable the reporter:
|
|
Add your webhook URL to the <webhookUrl>
property. You can also specify the webhook type as powerautomate
or msteams
. The default value is powerautomate
.
Mentioning users on failed tests
The playwright-msteams-reporter
also supports mentioning users in the message when a test fails. To enable this feature, you can add the mentionOnFailure
property to the configuration:
|
|
importantWhen a test fails, the reporter will mention the user(s).
Linking to the GitHub workflow run
If you are running your Playwright tests in a GitHub Actions workflow, you can add a link to the workflow run. To enable this feature, you can add the linkToResultsUrl
property to the configuration:
|
|
Running your tests
Once you have configured the reporter, you can run your Playwright tests. The reporter will send a message with the test results to the configured Microsoft Teams channel.
More configuration options are available for the playwright-msteams-reporter
. For more information, check out the playwright-msteams-reporter documentation.
Give it a try, and let me know your experiences. Feedback and suggestions are always appreciated!
Update
2024-07-09
Updated the article with the information of the retirement of Office 365 connectors within Microsoft Teams. Therefore, it is better to make use of the Power Automate webhook functionality to send messages to Microsoft Teams.