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.1.tar.gz (17.1 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.1-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_playwright_json-0.1.1.tar.gz
  • Upload date:
  • Size: 17.1 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.1.tar.gz
Algorithm Hash digest
SHA256 60913bab2406640d18ea52e6a4af0a6ada381d0954efd4dae33fd03bb72d3fa1
MD5 85118ec004ee06b9b2b96a327a25bdfd
BLAKE2b-256 f0721552016b78ba44dfe57594902564278ec120aba5f56018dcc7273dc98d8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_playwright_json-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6ec0da35993188bc8cb151b1b1c02138e8b9aac610e9b2af7c0ed444564a91cd
MD5 5b689ceec22fd3e4c22ad889f839ebc8
BLAKE2b-256 1be1eddc4a849eba9e829e63a136e3c1aac7c3d08c76de5f595c691cf0f5da4b

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