Effortlessly Publish Playwright Reports with GitHub Pages
Playwright is a great tool for automating browser tests, but one issue that can arise is how to share reports with team members or clients.
While you can easily run local reports using the command "npx playwright show-report", which opens a port on your computer, the challenge comes when you want to send the results to someone else.
Read on for Loop's tips on how to share reports:
One option is to zip up the reports folder and email it to the recipient, but they will need to run playwright and open the reports folder through an IDE to view the trace files.
Individual trace files:
Alternatively, they can use the trace.playwright.dev website to view trace files one at a time, but this can be inconvenient.
At Loop, our solution is to use GitHub actions to publish reports to a GitHub page. This allows anyone with internet access and the necessary credentials to view the report. Even better, all trace files are hosted within the report itself.
- To set this up, you'll need to turn on GitHub pages in the repository settings and set the source to GitHub actions. This will give you a default live site URL that is an extension of your base GitHub URL.
- It's important to note that for non-enterprise GitHub accounts, these pages are public, so sensitive information should not be included.
- When you first load the site, it will be empty, so you'll need to set up the GitHub actions to upload and deploy your artifact (in this case, the report).
- In the GitHub actions YAML file, you can use the "configure-pages" and "pages-artifact" actions to upload your artifact and deploy it to the pages.
- It's worth noting that as your test suite grows, it may take longer for the report to be published. However, this process is generally quick and reliable.
Using GitHub actions to publish playwright reports to a GitHub page is a convenient way to share test results with team members or clients.
It allows for easy access to all trace files and eliminates the need to deal with multiple trace files for different tests. Plus, it's hosted by GitHub, so there's no need to worry about hosting or maintenance on your end.
If you're working with playwright and looking for a way to share reports with others, consider using GitHub actions to publish them to a GitHub page.