Skip to main content

Generate Playwright-compatible JSON reports from pytest-playwright test runs

Project description

pytest-playwright-json

PyPI version Python License: MIT

Generate Playwright-compatible JSON reports from your Python tests

Quick Start

1. Install

pip install pytest-playwright-json

2. Run Tests

pytest --playwright-json=test-results/report.json

That's it! Your test results are now in Playwright's JSON format.

Why Use This?

  • TestDino Integration: Upload Python test results to TestDino dashboard
  • Playwright Format: Use tools designed for Playwright's native JSON reporter
  • Automatic Attachments: Screenshots, videos, and traces are included automatically
  • Zero Config: Works out of the box with sensible defaults

Installation

pip install pytest-playwright-json

Requirements:

  • Python 3.9 or higher
  • pytest 7.0 or higher
  • pytest-playwright (optional, for browser tests)

Usage

Basic Usage

# Generate JSON report
pytest --playwright-json=test-results/report.json

# With Playwright browser tests
pytest --playwright-json=test-results/report.json --browser=chromium

With pytest-html (Recommended)

pip install pytest-html

pytest \
  --playwright-json=test-results/report.json \
  --html=test-results/index.html \
  --self-contained-html

Configuration File

Add to your pyproject.toml:

[tool.pytest.ini_options]
addopts = [
    "--playwright-json=test-results/report.json",
    "--playwright-json-test-results-dir=test-results",
]

Or pytest.ini:

[pytest]
addopts = --playwright-json=test-results/report.json

Options

Option Description
--playwright-json=PATH Output path for JSON report
--playwright-json-test-results-dir=PATH Directory with test artifacts (auto-detected, rarely needed)
--playwright-json-include-attachments Include attachments in report (default: enabled)

Smart Defaults: The plugin automatically finds test artifacts by:

  1. Using pytest-playwright's --output directory if set
  2. Using the parent directory of your JSON report path
  3. Falling back to test-results

Attachments

The plugin automatically includes these attachments in your report:

Type Extensions
Screenshots .png, .jpg, .jpeg, .gif, .webp
Videos .webm, .mp4
Traces .zip

Upload to TestDino

Use with tdpw CLI to upload results:

# Install tdpw
pip install tdpw

# Run tests
pytest --playwright-json=test-results/report.json

# Upload to TestDino
tdpw upload test-results --token="your-token"

Example Test

from playwright.sync_api import Page, expect

def test_homepage(page: Page):
    page.goto("https://example.com")
    expect(page).to_have_title("Example Domain")

def test_navigation(page: Page):
    page.goto("https://example.com")
    page.click("a")
    expect(page).to_have_url("https://www.iana.org/domains/example")

Run with:

pytest tests/ --playwright-json=test-results/report.json --browser=chromium

Test Results

After running, you'll find:

test-results/
  report.json          # JSON report (Playwright format)
  index.html           # HTML report (if using pytest-html)
  test-name-chromium/  # Attachments for failed tests
    screenshot.png
    video.webm
    trace.zip

Troubleshooting

No attachments in report?

Make sure your JSON report is in the same directory as test artifacts:

# Recommended: Put report.json inside test-results/
pytest --playwright-json=test-results/report.json --output=test-results

pytest-playwright not found?

Install it:

pip install pytest-playwright
playwright install chromium

Support


Made with love by the TestDino team

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_playwright_json-0.1.0.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_playwright_json-0.1.0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file pytest_playwright_json-0.1.0.tar.gz.

File metadata

  • Download URL: pytest_playwright_json-0.1.0.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for pytest_playwright_json-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ee498e2280092f71cdfd06febdde9841c621a96ea35c1c63a376a91ab9463c9c
MD5 7ff34e85daa2ebcc436f80c80e34130e
BLAKE2b-256 db9afe150d00da2e73d68fb33b1e1891bf9d663c60670c9a3571038462278195

See more details on using hashes here.

File details

Details for the file pytest_playwright_json-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_playwright_json-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f850e429fa177d51dca971ea9c291a946d07c1f7d83658e0c6f8adcbf028e11
MD5 90e5d2838efc5823db881e4e25d5c31e
BLAKE2b-256 b4ea786db7ec2057d4a64dda7a27450f056a92424a2c94fc955b7b8a0c592a46

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page