A Playwright reporter that writes your test results to the job summary of a GitHub Actions run. It can also:
- show the error details of failed tests, with a link to the failing line
- show an overview of the failed and slowest tests
- explain why a run failed and expose the results as step outputs
- add workflow annotations on the failing lines
- add the results as a comment on the pull request
- show the screenshots of failed tests from blob storage
Note
The summary is only written when the tests run in GitHub Actions. When you run your tests locally, the reporter only passes through the console output of your tests.
Install from npm:
npm install @estruyf/github-actions-reporterAdd the reporter to your playwright.config.ts file:
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: [
['list'],
['@estruyf/github-actions-reporter']
],
});More information on how to use reporters can be found in the Playwright documentation.
With the useDetails option, each test file is shown as a collapsible section.
Pass the options as the second item of the reporter entry:
import { defineConfig } from '@playwright/test';
import type { GitHubActionOptions } from '@estruyf/github-actions-reporter';
export default defineConfig({
reporter: [
['@estruyf/github-actions-reporter', <GitHubActionOptions>{
title: 'My custom title',
useDetails: true,
showError: true
}]
],
});| Option | Description | Default |
|---|---|---|
| title | Title of the summary. Use an empty string ("") to remove the heading |
Test results |
| description | Markdown or HTML to show below the title. See Add context to the summary | "" |
| metadata | Key/value pairs to show as a list below the title. See Add context to the summary | {} |
| useDetails | Show each test file as a collapsible section | false |
| showTags | Show the tags of the tests | true |
| showAnnotations | Show the annotations of the tests, above the test row | true |
| showAnnotationsInColumn | Show the annotations in a column instead of above the test row. Requires showAnnotations |
false |
| includeResults | Which test results to show in the file sections: pass, fail, flaky and/or skipped |
['pass', 'skipped', 'fail', 'flaky'] |
| excludeProjects | Projects to leave out of the summary, as strings (exact project name) or regexes. See Exclude projects | [] |
| skipSummaryWhenAllPassed | Write no job summary when the run passed with no flaky tests. See Skip the summary when all tests passed | false |
| showArtifactsLink | Show a link to the artifacts section of the workflow run | false |
| quiet | Do not pass through the console output of the tests | false |
| debug | Log the reporter options to the console when the run starts | false |
| Option | Description | Default |
|---|---|---|
| showError | Show the errors of failed tests. See Error details | false |
| errorFormat | full shows the complete error message, short shows the first line of each error. Requires showError |
full |
| maxErrorLength | Maximum length of an error in the short format and in the failed tests overview |
180 |
| showErrorSnippet | Show the code around the failing line in a collapsible block. Only for the full format |
false |
| Option | Description | Default |
|---|---|---|
| showFailedOverview | Show a table with all failed tests at the top of the summary. See Failed and slowest tests | false |
| failedOverviewLimit | Maximum number of tests in the failed tests overview | 10 |
| showSlowestTests | Show a table with the N slowest tests at the top of the summary. Use 0 to turn it off |
0 |
| Option | Description | Default |
|---|---|---|
| workflowAnnotations | Add workflow annotations for failed and flaky tests. See Workflow annotations | false |
| prComment | Add the results as a comment on the pull request. See Comment on the pull request | false |
| prCommentId | Extra id to give each matrix job its own pull request comment. See Comment on the pull request | "" |
| githubToken | Token used to comment on the pull request | process.env.GITHUB_TOKEN |
| Option | Description | Default |
|---|---|---|
| azureStorageUrl | URL of the Azure Storage container where the screenshots are stored. See Showing result attachments | "" |
| azureStorageSAS | Shared Access Signature (SAS) token to upload to the Azure Storage container | "" |
| githubStorage | Store the images in the git storage of the repository, true or { refPrefix, maxUploads, requestTimeout }. See GitHub repository storage |
false |
| uploadAttachment | Function that uploads an image attachment to your own storage and returns its URL. See Custom storage | undefined |
Use the description and metadata options to show extra context between the title and the results, for example the tested environment or why this set of tests ran. The context is shown in the job summary and in the pull request comment.
import { defineConfig } from '@playwright/test';
import type { GitHubActionOptions } from '@estruyf/github-actions-reporter';
export default defineConfig({
reporter: [
['@estruyf/github-actions-reporter', <GitHubActionOptions>{
description: `Selection: **${process.env.SELECTION_MODE}**`,
metadata: {
Environment: process.env.TEST_ENV,
Target: process.env.TEST_TARGET ?? 'all tests',
}
}]
],
});descriptionsupports markdown and HTML.metadatais shown as a list. Entries with an empty,nullorundefinedvalue are skipped, so you can use environment variables that are not always set.
With showError: true, the summary gets an Error column with:
- all errors of the test, for example every failed
expect.soft() - the cause of the error, when there is one
- a link to the failing line on GitHub, for example
fail.spec.ts:22 - the
test.stepor hook in which the test failed, for exampleFailed at: Checkout › Add to cart (SKU 42)
Error messages from Playwright can be long, as they include the call log and the expected and received values. To keep the tables compact, use errorFormat: 'short'. It shows the first line of each error, without colors, and cuts it off at maxErrorLength characters.
With showErrorSnippet: true, the code around the failing line is added in a collapsible block. This only works with the full format. The snippets are left out of the pull request comment, as they can make the comment too large.
['@estruyf/github-actions-reporter', <GitHubActionOptions>{
showError: true,
errorFormat: 'short',
maxErrorLength: 120
}]When a run has many test files, the overview tables show what matters at the top of the summary:
showFailedOverview: trueadds a "Failed tests" table with the file, test and short error of every failed and timed out test. It is only shown when at least one test failed andfailis part ofincludeResults. When there are more thanfailedOverviewLimitfailed tests, the rest is shown as a "+N more failed tests" line.showSlowestTests: 5adds a "Slowest tests" table with the 5 slowest tests, sorted by the duration of their slowest attempt. Skipped tests are left out.
When you use project dependencies, for example to sign in before the tests run, the setup projects show up as their own sections in the summary. Use the excludeProjects option to leave them out:
import { defineConfig } from '@playwright/test';
import type { GitHubActionOptions } from '@estruyf/github-actions-reporter';
export default defineConfig({
reporter: [
['@estruyf/github-actions-reporter', <GitHubActionOptions>{
excludeProjects: ['setup', /^setup-/]
}]
],
});A string matches the full project name, a regex is tested against it. The tests of excluded projects are left out of the totals, the overview tables, the file sections and the pull request comment.
Note
An excluded project with a failed test is still shown, including in the totals. When a setup project fails, all tests that depend on it are skipped, so the failure explains why.
When a workflow runs many jobs, GitHub shows only the first few job summaries and hides the rest behind "Load summary". Use the skipSummaryWhenAllPassed option to only write a summary for the jobs that need attention:
import { defineConfig } from '@playwright/test';
import type { GitHubActionOptions } from '@estruyf/github-actions-reporter';
export default defineConfig({
reporter: [
['@estruyf/github-actions-reporter', <GitHubActionOptions>{
includeResults: ['fail', 'flaky'],
skipSummaryWhenAllPassed: true
}]
],
});- The summary is skipped when the run passed and no test was flaky. Skipped tests do not count, so a run with only passed and skipped tests, or without tests, has no summary. The log shows
Job summary skipped: all tests passed. - A run that failed, timed out or was interrupted, or has a flaky test, writes the summary as usual.
- Only the job summary is skipped. The step outputs, workflow annotations and the pull request comment still work, so the comment of an earlier failed run is updated with the passed results.
If you want to show attachments like when you use pixel matching, you need to configure where the images will be stored. You can use:
- Azure Blob Storage
- GitHub repository storage, which stores the images in the repository itself, so no external storage is needed
- Custom storage, with your own upload function
Note
GitHub does not have an API to upload images to the summary. Therefore, the images are stored in one of the above and the summary links to them.
Important
To show the attachments, you need to make sure to enable showError as well.
If you are using Azure Blob Storage, you need to provide the azureStorageUrl and azureStorageSAS configuration options.
Follow the next steps to get the URL and SAS token:
- Go to your Azure Portal
- Navigate to your storage account or create a new one
- Navigate to data storage > containers
- Create a new container. Set the access level to Blob (anonymous read access for blobs only)
- Open the container, and click on Shared access signature
- Create a new shared access signature with the following settings:
- Allowed permissions: Create
- Expiry time: Custom (set the time you want)
- Allowed protocols: HTTPS only
- Click on Generate SAS and URL
- Copy the Blob SAS token, this will be your
azureStorageSASvalue - Copy the Blob service URL and append the container name to it, this will be your
azureStorageUrlvalue. Example:https://<name>.blob.core.windows.net/<container-name>. - Update the
playwright.config.tsfile with the following configuration:
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: [
['@estruyf/github-actions-reporter', {
showError: true,
azureStorageUrl: 'https://<name>.blob.core.windows.net/<container-name>',
azureStorageSAS: '<your-sas-token>'
}]
],
});The images can be stored in the git storage of the repository that runs the workflow, so no external storage is needed. This also works for private repositories: GitHub shows github.com/<owner>/<repo>/blob/<sha>/<file>?raw=true images with the session of the viewer, so only people with access to the repository can see them.
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
screenshot: 'only-on-failure',
},
reporter: [
['@estruyf/github-actions-reporter', {
showError: true,
githubStorage: true,
}]
],
});The token needs to be able to write to the repository:
permissions:
contents: write
steps:
- name: Run Playwright tests
run: npx playwright test
env:
GITHUB_TOKEN: ${{ github.token }}- The images of the last attempt of each test shown in the summary are uploaded in one commit, under
refs/<refPrefix>/<YYYY-MM-DD>/<run id>/<run attempt>/<uuid>. The ref is not a branch, so it does not show up in the branch list and is not fetched by a normal clone. refPrefixchanges the prefix of the refs. Default:test-attachments.maxUploadslimits the number of image uploads per reporter, so per job or shard, so a run with many failures does not hit the rate limit of the GitHub API. Failed uploads count as well, so it also caps the time spent on uploads. The other images are left out. Default:30.requestTimeoutis the timeout of a GitHub API request in seconds. Uploading an image gets three times as long. When a request gets no response in time, the remaining images are not uploaded, so a hanging API does not keep the job waiting. Default:10.- The token is the
githubTokenoption, orGITHUB_TOKEN. Without a token, or outside of a workflow, no images are uploaded and the log says why. On GitHub Enterprise Server,GITHUB_API_URLandGITHUB_SERVER_URLare used. - Azure Blob Storage, when configured, is used instead.
showErrorneeds to be enabled, as the images are shown next to the error. - The log shows the number of uploaded images, the ref and the remaining GitHub API rate limit. When an upload fails, the summary is shown without the image and a workflow warning explains why. Pull requests from forks get a read-only token, so their summary has no images.
Important
- In a public repository, the images are public as well.
- The refs are not removed automatically. Delete the old refs, for example with a scheduled workflow (change
test-attachments/when you use anotherrefPrefix):
name: Delete old test attachments
on:
schedule:
- cron: '0 3 * * *'
permissions:
contents: write
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v8
with:
script: |
const retentionDays = 7;
const cutoff = Date.now() - retentionDays * 24 * 60 * 60 * 1000;
const refs = await github.paginate(github.rest.git.listMatchingRefs, {
...context.repo,
ref: 'test-attachments/',
});
for (const { ref } of refs) {
// refs/test-attachments/<YYYY-MM-DD>/...
const date = ref.split('/')[2];
if (new Date(`${date}T23:59:59Z`).getTime() < cutoff) {
await github.rest.git.deleteRef({ ...context.repo, ref: ref.replace(/^refs\//, '') });
core.info(`Deleted ${ref}`);
}
}To use any other storage (AWS S3, Google Cloud Storage, Cloudflare R2, your own server, ...), provide an uploadAttachment function. The reporter calls it for every image attachment of the last test attempt, and shows the returned URL in the Attachments column.
- The function receives the attachment
name,path(local file) andcontentType. - Return the URL of the uploaded image, or
undefinedto leave it out. - When the function throws, the error is logged and the attachment is left out. The run itself does not fail.
- When Azure Blob Storage or
githubStorageis configured, that storage is used instead.
Note
GitHub loads the images of the summary through its image proxy, without your credentials. The URL needs to be readable without authentication.
import { defineConfig } from '@playwright/test';
import type { AttachmentUploader } from '@estruyf/github-actions-reporter';
const uploadAttachment: AttachmentUploader = async ({ path, contentType }) => {
// Upload the file to your storage, and return its public URL
return await uploadToYourStorage(path, contentType);
};
export default defineConfig({
use: {
screenshot: 'only-on-failure',
},
reporter: [
['@estruyf/github-actions-reporter', {
showError: true,
uploadAttachment,
}]
],
});When a run fails, the summary shows why, below the test totals, for example 2 failed, 1 timed out. The same message is used for the failed step in the workflow. It also covers runs that fail without a failing test:
- Flaky tests with
failOnFlakyTests: the flaky tests get the ❌ icon and the message says1 flaky test (failOnFlakyTests is enabled). - Global timeout or an interrupted run:
Global timeout reachedorTest run was interrupted. - Errors outside of tests: a failing global setup or teardown, or a worker fixture that fails during teardown. These errors are shown in an "Errors outside of tests" section at the top of the summary, also when
showErroris turned off.
The reporter sets the test results as outputs of the step that runs your tests, so later steps can use them:
| Output | Description |
|---|---|
total |
Total number of tests |
passed |
Number of passed tests |
failed |
Number of failed tests |
flaky |
Number of tests that passed on a retry |
skipped |
Number of skipped tests |
timed-out |
Number of tests that timed out |
status |
Status of the run: passed, failed, timedout or interrupted |
Give the step an id to use them:
- name: Run Playwright tests
id: playwright
run: npx playwright test
- name: Upload the report when tests failed
if: ${{ !cancelled() && steps.playwright.outputs.failed != '0' }}
uses: actions/upload-artifact@v7
with:
name: playwright-report
path: playwright-report/With the workflowAnnotations option, the reporter adds a workflow annotation for each failed test. Annotations are shown on the workflow run, and inline on the "Files changed" tab of a pull request when the pull request changes the annotated file:
- Failed and timed out tests get an error on the line where the test failed.
- Flaky tests get a warning, or an error when
failOnFlakyTestsis enabled. - Errors outside of tests, like a failing global setup, get an error as well.
Note
Playwright's built-in github reporter also adds annotations. Do not enable this option when you use both reporters, or each failure is annotated twice. GitHub shows at most 10 errors and 10 warnings per step.
Next to the job summary, the reporter can add the test results as a comment on the pull request. When the workflow runs again, the reporter updates its existing comment instead of adding a new one.
To enable it:
-
Set the
prCommentoption totrue:import { defineConfig } from '@playwright/test'; import type { GitHubActionOptions } from '@estruyf/github-actions-reporter'; export default defineConfig({ reporter: [ ['@estruyf/github-actions-reporter', <GitHubActionOptions>{ prComment: true }] ], });
-
Run the workflow on the
pull_requestevent, give it thepull-requests: writepermission, and pass theGITHUB_TOKENto the Playwright step:on: pull_request: permissions: contents: read pull-requests: write jobs: test: runs-on: ubuntu-latest steps: # ... - name: Run Playwright tests run: npx playwright test env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Note
The comment is only added when the workflow runs for a pull request. If the comment fails (for example, pull requests from forks get a read-only token), the reporter logs a warning and does not fail the run.
Each reporter gets its own comment per workflow job and title. The jobs of a matrix share the same workflow job, so they would update the same comment:
-
Sharded runs get one comment per shard automatically. To get a single comment for all shards, see Sharding.
-
Other matrix setups need a unique
prCommentIdper matrix job. Pass the matrix value through an environment variable, as the Playwright config cannot read the matrix directly:- name: Run Playwright tests run: npx playwright test env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TEST_TARGET: ${{ matrix.target }}
['@estruyf/github-actions-reporter', <GitHubActionOptions>{ prComment: true, prCommentId: process.env.TEST_TARGET }]
When you shard your tests, each shard writes its own summary. The title shows which shard it belongs to, for example Test results (shard 2/4).
To get one summary for all shards instead, let each shard write a blob report, and merge the reports in a separate job with a config that uses this reporter. The merged summary has no shard label.
-
Use the
blobreporter for the shards:reporter: process.env.CI ? [['blob']] : 'html',
To keep the summary per shard as well, add this reporter next to it:
[['blob'], ['@estruyf/github-actions-reporter']]. -
Create a
merge.config.tsfor the merge job:import type { GitHubActionOptions } from '@estruyf/github-actions-reporter'; export default { testDir: './tests', reporter: [ ['@estruyf/github-actions-reporter', <GitHubActionOptions>{ title: 'All test results', showError: true }] ], };
For a single pull request comment with the results of all shards, set
prCommentin this config only, and pass theGITHUB_TOKENto the merge step. -
Upload the
blob-reportfolder of each shard as an artifact, download them all in the merge job, and run:npx playwright merge-reports --config=merge.config.ts ./all-blob-reports
The sharding sample workflow of this repository shows the full setup, with playwright.sharding.config.ts for the shards and playwright.merge.config.ts for the merge job.


