An open API service indexing awesome lists of open source software.

https://github.com/daun/playwright-report-summary

A GitHub action to report Playwright test results as pull request comments
https://github.com/daun/playwright-report-summary

comments github-actions job-summary playwright pull-requests test-results

Last synced: 2 months ago
JSON representation

A GitHub action to report Playwright test results as pull request comments

Awesome Lists containing this project

README

        

# ![report](https://icongr.am/octicons/comment-discussion.svg?size=22&color=abb4bf)   Playwright Report Summary

[![GitHub Super-Linter](https://github.com/actions/typescript-action/actions/workflows/linter.yml/badge.svg)](https://github.com/super-linter/super-linter)
![CI](https://github.com/actions/typescript-action/actions/workflows/ci.yml/badge.svg)

A GitHub action to report Playwright test results as a pull request comment.

- Parse the JSON test report generated by Playwright
- Generate a markdown summary of the test results
- Post the summary as a pull request comment
- Uses GitHub's official [icons](https://primer.style/design/foundations/icons) and [color scheme](https://primer.style/design/foundations/color)

## Examples

## Usage

### Basic usage

Playwright must be configured to [generate a JSON report](https://playwright.dev/docs/test-reporters#json-reporter)
and write it to disk. This action receives the report file path as input, in this case `results.json`.

Note the `if: always()` to ensure the report comment is created even if the tests failed.

```yaml
jobs:
test:
name: Run playwright tests
needs: install
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20

- run: PLAYWRIGHT_JSON_OUTPUT_NAME=results.json npx playwright test --reporter=json

- uses: daun/playwright-report-summary@v3
if: always()
with:
report-file: results.json
```

### Usage with custom commenting logic

The action will do the work of creating comments and updating them whenever tests re-run. If you
require custom logic for creating and updating comments, you can disable the default logic and use
any other action in combination with the `summary` output of this action.

A few recommended actions are
[Sticky Pull Request Comment](https://github.com/marketplace/actions/sticky-pull-request-comment)
and [Create or Update Comment](https://github.com/marketplace/actions/create-or-update-comment).

```diff
- uses: daun/playwright-report-summary@v3
if: always()
id: summary
with:
report-file: results.json
+ create-comment: false

+ - uses: marocchino/sticky-pull-request-comment@v2
+ with:
+ message: ${{ steps.summary.outputs.summary }}
```

## Options

```yaml
- uses: daun/playwright-report-summary@v3
if: always()
with:
# The GitHub access token to use for API requests
# Defaults to the standard GITHUB_TOKEN
github-token: ''

# Path to the JSON report file generated by Playwright. Required.
report-file: 'result.json'

# A unique tag to represent this report when reporting on multiple test runs
# Defaults to the current workflow name
report-tag: ''

# URL to a published html report, uploaded by another action in a previous step.
# Example pipeline: https://playwright.dev/docs/test-sharding#publishing-report-on-the-web
report-url: 'https://user.github.io/repo/yyyy-mm-dd-id/'

# Whether the action should create the actual comment. Set to false to implement
# your own commenting logic.
# Default: true
create-comment: true

# Title/headline to use for the created pull request comment.
# Default: 'Playwright test results'
comment-title: 'Test results'

# Additional information to include in the summary comment, markdown-formatted
# Default: ''
custom-info: 'For more information, [see our readme](http://link)'

# Create a job summary comment for the workflow run
# Default: false
job-summary: false

# Icon style to use: octicons | emojis
# Default: octicons
icon-style: 'octicons'

# Command used to run tests. If provided, a command to re-run failed or
# flaky tests will be printed for each section.
# Default: ''
test-command: 'npm run test --'

# Additional content to add to the comment below the test report.
# Default: ''
footer: ''
```

## Output

The action creates two output variables:

### summary

The rendered markdown summary of the test report.

### comment-id

The ID of the comment that was created or updated

# License

[MIT](./LICENSE)