Skip to main content

Python bridge for Playwright Smart Reporter - AI-powered test analysis and reporting

Project description

Playwright Smart Reporter - Python

Python integration for Playwright Smart Reporter - brings AI-powered failure analysis, flakiness detection, and beautiful HTML reports to your pytest test suites.

Features

All the features from the main Playwright Smart Reporter, now available for Python/pytest:

  • AI Failure Analysis - Claude/OpenAI/Gemini powered suggestions
  • Smart Analytics - Flakiness detection, performance regression alerts
  • Trend Charts - Visual history of test health over time
  • Stability Scoring - A+ to F grades for test reliability
  • Failure Clustering - Group similar errors automatically
  • Modern Dashboard - Interactive sidebar navigation, light/dark themes

Prerequisites

  • Python 3.9+
  • Node.js 18+ (runtime only - no npm install needed)

Installation

pip install playwright-smart-reporter-python

The package is self-contained. The compiled JavaScript report generator is bundled in the wheel - Node.js is only needed at runtime to execute it.

Quick Start

Option 1: Pytest Plugin (Automatic)

Run your tests with the --smart-reporter flag:

pytest --json-report --smart-reporter

Report automatically generated at smart-report.html.

Option 2: Manual Generation

from playwright_smart_reporter_python import SmartReporterBridge

bridge = SmartReporterBridge()
bridge.generate_report(
    pytest_json_path=".pytest-report.json",
    output_html="smart-report.html"
)

Configuration

pytest.ini / pyproject.toml

[pytest]
addopts =
    --json-report
    --json-report-file=.pytest-report.json
    --smart-reporter
    --smart-reporter-output=test-reports/smart-report.html

Environment Variables

# AI Analysis (optional)
export ANTHROPIC_API_KEY="sk-ant-..."
export OPENAI_API_KEY="sk-..."
export GEMINI_API_KEY="..."

Usage with Playwright for Python

# test_example.py
from playwright.sync_api import Page

def test_homepage(page: Page):
    page.goto("https://playwright.dev")
    assert page.title() == "Fast and reliable end-to-end testing"
pytest --headed --smart-reporter

How It Works

  1. pytest runs your tests with JSON reporting enabled
  2. Converter transforms pytest JSON to Playwright Smart Reporter format
  3. Node.js bridge calls the bundled HTML generator
  4. Output interactive HTML report

Development

This is part of a monorepo. The Python package lives in python/ and can use either the bundled JS dist (PyPI install) or the monorepo dist/ (local development).

# From repository root
npm run build                      # Compile TypeScript
cd python
python scripts/bundle_dist.py      # Bundle JS into package
pip install -e ".[dev]"            # Editable install
pytest tests/ -v                   # Run tests

Troubleshooting

Node.js not found

The package needs Node.js at runtime to execute the report generator:

# macOS
brew install node

# Linux
sudo apt install nodejs

# Windows
# Download from https://nodejs.org

License

MIT - See LICENSE.

Related

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

playwright_smart_reporter_python-1.0.7.tar.gz (113.0 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file playwright_smart_reporter_python-1.0.7.tar.gz.

File metadata

File hashes

Hashes for playwright_smart_reporter_python-1.0.7.tar.gz
Algorithm Hash digest
SHA256 dd6aee23370f9633b7807003c8871d8cad4be8f0b029d3b6af97e3ef7ade1ae8
MD5 749a70ad53d10532c4bf0257076c9ac5
BLAKE2b-256 24d7494722acfc24883c702dc116e34fdb5c879d4cb8d748f8d72080de44515c

See more details on using hashes here.

Provenance

The following attestation bundles were made for playwright_smart_reporter_python-1.0.7.tar.gz:

Publisher: publish-python.yml on qa-gary-parker/playwright-smart-reporter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file playwright_smart_reporter_python-1.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for playwright_smart_reporter_python-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e1c01244f3f74caeaec8e07d5087d28b79071d6a7db41a8b538e65aa707d8e75
MD5 7435b0075c61048008434629999b7c96
BLAKE2b-256 4a2eded4954cffe6d5a86211f51781f8d46a73aea23c4331dd99dd503dcd4438

See more details on using hashes here.

Provenance

The following attestation bundles were made for playwright_smart_reporter_python-1.0.7-py3-none-any.whl:

Publisher: publish-python.yml on qa-gary-parker/playwright-smart-reporter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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