Generate Playwright-compatible JSON reports from pytest-playwright test runs
Project description
pytest-playwright-json
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:
- Using pytest-playwright's
--outputdirectory if set - Using the parent directory of your JSON report path
- 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 testdino CLI to upload results:
# Install testdino
pip install testdino
# Run tests
pytest --playwright-json=test-results/report.json
# Upload to TestDino
testdino 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
- Documentation: testdino.com/docs
- Issues: GitHub Issues
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_playwright_json-0.1.2.tar.gz.
File metadata
- Download URL: pytest_playwright_json-0.1.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
874c72fb6475d4ba9859c97b1b880c7e5e1f53c1849e64997cb1c2681edb915a
|
|
| MD5 |
84e780017db0ada0670909e33fdc320d
|
|
| BLAKE2b-256 |
dbb9e541bc46ee4cce2bf1b9dde5fdcc4c42a86454357a77f79add3ab3d540b3
|
File details
Details for the file pytest_playwright_json-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pytest_playwright_json-0.1.2-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f505ca2949a425571702861888a9f2cf9991e6de284715f533bc694aaf83c7f8
|
|
| MD5 |
450cb79c032ad3d448c4e3ea288a686e
|
|
| BLAKE2b-256 |
916e98b10bfc5690d431769df2aabab75a2afa07577b51601ad7c213d425987b
|