Metadata-Version: 2.4
Name: velvet-report
Version: 2.1.4
Summary: VelvetReport — Universal JUnit XML to self-contained offline HTML test reporter. Works with pytest, Playwright, Maven, Jest, Cypress, Robot Framework.
Home-page: https://github.com/DwivediTarun/offline_velvet_report
Author: VelvetReport Contributors
Author-email: hello@velvetreport.dev
Keywords: velvet-report test-report junit pytest playwright html-report offline allure-alternative extent-report robot-framework ci-report test-results velvetreport
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Pytest
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: requires-python
Dynamic: summary

# VelvetReport — Universal JUnit XML to Offline HTML Test Reporter

[![PyPI version](https://img.shields.io/pypi/v/velvet-report?color=3b82f6&label=pip)](https://pypi.org/project/velvet-report/)
[![npm version](https://img.shields.io/npm/v/velvet-report?color=22c55e&label=npm)](https://www.npmjs.com/package/velvet-report)
[![Maven Central](https://img.shields.io/maven-central/v/dev.velvetreport/velvet-report?color=f59e0b)](https://central.sonatype.com/artifact/dev.velvetreport/velvet-report)
[![License: MIT](https://img.shields.io/badge/license-MIT-a855f7)](https://github.com/DwivediTarun/offline_velvet_report/blob/main/LICENSE)
[![Zero Dependencies](https://img.shields.io/badge/dependencies-0-22c55e)](https://github.com/DwivediTarun/offline_velvet_report)
[![Self-Tests](https://img.shields.io/badge/self--tests-25%2F25%20passing-22c55e)](https://github.com/DwivediTarun/offline_velvet_report)

> **VelvetReport** is a zero-dependency, self-contained, 100% offline HTML test reporting engine. It converts standard JUnit XML output into an interactive, single-file dashboard with historical trend tracking, flaky test detection, execution timelines, and failure analytics. Built as a lightweight, zero-server alternative to **Allure Report** and **ExtentReports** across Python, Node.js, and Java.

---

### ⚡ 10-Second Quickstart

#### Python (`pytest` — Zero Config):
```bash
pip install velvet-report
pytest   # Report auto-generated at reports/velvetreport.html with zero config!
```

#### Node.js (`npx` — Zero Install):
```bash
npx velvet-report generate reports/results.xml ./reports --open
```

#### Java (`Maven`):
```xml
<dependency>
  <groupId>dev.velvetreport</groupId>
  <artifactId>velvet-report</artifactId>
  <version>2.1.3</version>
</dependency>
```

---

### 🥊 Why VelvetReport? (Comparison Matrix)

| Feature | VelvetReport (v2.1.3) | Allure Report | pytest-html / Mochawesome |
|---|:---:|:---:|:---:|
| **100% Offline (No CDN/Internet)** | ✅ Single file, zero network calls | ⚠️ Requires Java runtime / HTTP server | ✅ Single static file |
| **Zero Server / Zero Setup** | ✅ Double-click file to open in browser | ❌ Requires `allure serve` or cloud host | ✅ Static file |
| **Zero Runtime Dependencies** | ✅ **0 dependencies** | ❌ Heavy CLI / JVM setup | ⚠️ Multiple packages |
| **Historical Trends & Flaky Tracking** | ✅ Auto-saved in `.history/` (~3 KB/run) | ⚠️ Needs Allure Server / DB | ❌ None |
| **Pytest Auto-Capture** | ✅ Environment, fixtures, xdist, tags | ⚠️ Requires manual decorators | ⚠️ Limited |
| **Interactive Test Details Drawer** | ✅ Summary, Traces, Steps, Screenshots | ✅ Supported | ⚠️ Limited |
| **Multi-Framework Parity** | ✅ Python, Node.js, Java | ⚠️ Framework-specific adapters | ❌ Single framework |
| **Failure Classification** | ✅ Auto-detects Assertion / Timeout / Network | ⚠️ Manual classification | ❌ None |

---

## 🚀 Key Highlights (v2.1.3)

- 📴 **100% Offline & Self-Contained**: One standalone `.html` file. Inlines all CSS, JS, charts, and base64 screenshots. Zero external network calls.
- ⚡ **Zero-Config Pytest Auto-Capture**: Automatically captures OS, Python runtime, CI variables, git branch, marks, setup/call/teardown timings, fixture overheads, and xdist worker distribution.
- 🎯 **Interactive Test Details Drawer**: Per-test **Summary** (Date, Duration, Failure Cause, Screenshot thumbnail), **Stack Trace**, **Run History** (30-run trend dots), **Logs**, **Tags & Steps**, and **Attachments** lightbox.
- 📈 **History & Flaky Detection**: Automatically tracks up to 30 previous test runs in lightweight `.history/` files and highlights flaky tests across runs.
- 📊 **10+ Rich Interactive Visualizations**: Donut pass/fail charts, duration histograms, volume trends, worker distribution, failure categorization, and collapsible Mind Map navigation.
- 🧩 **Universal Compatibility**: Works with **pytest, Playwright, Jest, Cypress, Robot Framework, Vitest, TestNG, JUnit 5**, and any tool outputting JUnit XML.

---

## Testing Frameworks Integration & Reporting

VelvetReport acts as a modern, self-contained reporting system. While **test execution** runs your test scripts (performing assertions, API requests, and browser interactions), **test reporting** structures these outcomes into an easily readable, interactive dashboard containing diagnostics, logs, trends, and attachments.

---

### Python (pytest / Playwright) Integration

VelvetReport provides native, zero-config reporting for Python testing using `pytest`. The `velvet-report` pytest plugin automatically hooks into your tests to capture run telemetry and environment info.

#### 1. Why Reporting is Required
- **Analyze Failures**: Instantly pinpoint why a Python browser or API test failed.
- **Diagnostics**: View duration, error stack traces, and system-under-test environments.
- **Evidence Collection**: Access screenshots and logs associated with failed tests.
- **CI/CD Insights**: Track execution trends over multiple builds using historical data.

#### 2. Prerequisites & Installation
Ensure you have Python **>= 3.8**. Install the required packages via `pip`:
```bash
# Install pytest, playwright, and the VelvetReport collector
pip install pytest pytest-playwright velvet-report

# Install browser binaries for Playwright
playwright install
```

#### 3. Reporting Configuration
VelvetReport is configured directly in your `pytest.ini` file at the root of your project:
```ini
[pytest]
# Direct pytest to output JUnit XML to the reports folder
addopts = --junitxml=reports/results.xml

# VelvetReport specific configurations
vReport_Title               = Playwright Python Suite
vReport_output              = reports
vReport_history             = reports/.history
vReport_open                = false
vReport_embed_max           = 2M
vReport_email_report_enable = false
```
* **vReport_Title**: Custom title shown in the report topbar.
* **vReport_output**: The directory where the final `velvetreport.html` is built (default: `reports`).
* **vReport_history**: History trend logs directory (default: `reports/.history`).
* **vReport_embed_max**: Limits the maximum file size (e.g. `2M` for 2 megabytes) of attachments embedded directly as base64 inside the offline HTML.

#### 4. Supported Capabilities
- **Execution Timings**: Timings of setup, call, and teardown test phases, including fixture overheads.
- **Worker/Platform Dist**: Track test distribution across multiple workers (when using `pytest-xdist`).
- **Assertion vs. Timeout Identification**: Auto-categorizes errors into Assertion, Timeout, Network, or Script.
- **Automatic Attachment Discovery (Playwright)**: On failed tests, VelvetReport automatically scans the Playwright `test-results/` directory, extracts screenshots, and encodes them directly into the report.
- **Manual Attachments**: Manually attach logs, videos, or screenshots in code:
  ```python
  import velvet_report.get_pytest_data as vr

  def test_homepage(page):
      page.goto("https://playwright.dev")
      # Add step metadata
      with vr.step("Capture screenshot"):
          vr.attach(page.screenshot(), name="home.png", mime="image/png")
  ```

#### 5. Run Tests and Generate Report
To run your test suite and automatically generate the VelvetReport HTML dashboard:
```bash
# Run pytest (VelvetReport executes as a plugin and compiles the HTML dashboard)
pytest
```
The report is generated at: **`reports/velvetreport.html`**

#### 6. Open the Report
Open the generated HTML dashboard file directly in any browser — no local server is required:
```bash
# On Windows
start reports/velvetreport.html

# On macOS
open reports/velvetreport.html
```
Click on any failed test in the suite tree to inspect step logs, stack traces, and embedded screenshots.

#### 7. Customization Options
- **Command Line Overrides**:
  ```bash
  pytest --vReport-title "Staging Regression Run" --vReport-output custom-reports --vReport-open
  ```
- **Filter and Search**: The UI supports full tag filters (e.g. `@smoke`, `@regression`), text search, and test status toggles.

#### 8. CI/CD Usage
In CI/CD (such as GitHub Actions), run tests, archive the generated HTML report, and review the dashboard in pipeline artifacts.
```yaml
# .github/workflows/test.yml snippet
- name: Run Pytest Suite
  run: pytest
- name: Archive Test Report
  if: always()
  uses: actions/upload-artifact@v4
  with:
    name: velvetreport
    path: reports/velvetreport.html
```

---

## Report Features

### Metrics & KPIs
- **12 KPI cards** — Total, Passed, Failed, Errors, Skipped, Rerun, Pass Rate, Avg Test Time, Total Duration, Stability Score (0–100), Flaky %, Failure Reproducibility — animated count-up on view.
- **Risk badge** — STABLE / UNSTABLE / HIGH RISK.
- Click any KPI card → modal listing the exact test cases behind it.

### Test Details Drawer
- Expandable suite tree with per-test tabs: **Summary** (phases/fixtures/reason/thumbnail), **Stack Trace**, **Run History**, **Logs**, **Tags & Steps**, **Screenshots**, **Attachments**.
- **Run history** — per-run status, duration, date/time, failure reason, screenshot — mapped correctly by file + test name across 30 runs.
- **FLAKY badge** — auto-detected vs previous runs.
- Live search + filter (All / Passed / Failed / Skipped / Flaky).

### Visual Analysis & Charts
- **Test Execution Timeline** — animated per-test bars.
- **Mind Map** — Root → Suite → Describe → Test, clickable nodes open full detail.
- **Failure Analysis** — auto-classified: Assertion / Timeout / Network / Script, with screenshot preview in modal.
- **Pass/Fail donut, Duration histogram, Volume & Outcome Trends, Duration Trends, Test Distribution by Worker, Browser Distribution, Top 10 Slowest, Suite Health**.

---

---

## 📧 Automated Executive Email Summary Report

In addition to the full interactive dashboard (`velvetreport.html`), VelvetReport generates an ultra-clean, email-client-friendly single-file HTML summary: **`velvetreport_email.html`**.

### 🌟 Key Highlights of the Email Report
- **Executive Snapshot**: Designed specifically for CI/CD notifications (GitHub Actions, GitLab CI, Jenkins, Slack/Teams email dispatch, Outlook, Gmail, Apple Mail).
- **Zero External Scripts**: 100% inline CSS and HTML table structure that renders reliably without being blocked by corporate email spam filters or mail user agents.
- **Delta Trend Metrics (`162 | ↑ 5`)**: Metric cards showcase pass/fail/total/flaky comparisons against the previous test execution (e.g., `162 | ↑ 5` or `12 | ↓ 2`).
- **Timing & Execution Banner**: Highlights Start Time, End Time, Duration, Git Branch, and Framework runtime metadata at the top.
- **New vs. Repeated Failures**: Distinguishes newly emerging test failures (`[NEW FAIL]`) from recurrent failures (`[REPEATED FAIL]`) with visual alert badges.

### How to Generate the Email Report

#### 1. Via Command-Line Interface (CLI)
- **Python / pytest**:
  ```bash
  pytest --vReport-email
  ```
- **Node.js / npx / global CLI**:
  ```bash
  velvet-report generate reports/results.xml ./reports --email
  # or using npx directly
  npx velvet-report generate reports/results.xml ./reports --email
  ```

#### 2. Via `pytest.ini` Configuration (Python)
Add `vReport_email = true` (or its alias `vReport_email_report_enable = true`) to your `pytest.ini`:
```ini
[pytest]
addopts = --junitxml=reports/results.xml

# Generate email-ready HTML summary alongside velvetreport.html
vReport_email               = true
vReport_email_report_enable = true
vReport_output              = reports
```

#### 3. Programmatically in Python
```python
from velvet_report import generate_report

# Generates reports/velvetreport.html AND reports/velvetreport_email.html
generate_report(
    junit_xml="reports/results.xml",
    output_dir="reports",
    email_en=True,                # Enable email HTML generation
    title="Nightly Regression Suite"
)
```

#### 4. Programmatically in Node.js / JavaScript / TypeScript
```javascript
const { generate, buildEmailHtml, parseJunit } = require('velvet-report');

// Option A: Generate both reports to disk
generate('reports/results.xml', './reports', {
  title: 'CI Test Run',
  email: true // writes reports/velvetreport_email.html
});

// Option B: Generate raw email HTML in-memory to send via Nodemailer / SendGrid
const fs = require('fs');
const xml = fs.readFileSync('reports/results.xml', 'utf8');
const report = parseJunit(xml, 'results.xml');
const emailHtml = buildEmailHtml(report);
```

#### 5. CI/CD Notification Dispatch (GitHub Actions)
```yaml
- name: Run Tests & Generate Reports
  run: pytest --vReport-email
  if: always()

- name: Send Email Report Notification
  if: always()
  uses: dawidd6/action-send-mail@v3
  with:
    server_address: smtp.gmail.com
    server_port: 465
    username: ${{ secrets.MAIL_USERNAME }}
    password: ${{ secrets.MAIL_PASSWORD }}
    subject: "Test Execution Summary: ${{ github.repository }} (#${{ github.run_number }})"
    html_body: file://reports/velvetreport_email.html
    to: team-qa@example.com
```

---

## Configuration Reference

### Python (`pytest.ini` & CLI Options)

| Key | CLI Flag | Default | Description |
|-----|----------|---------|-------------|
| `vReport_Title` | `--vReport-title <text>` | XML filename | Custom report title shown in dashboard header |
| `vReport_output` | `--vReport-output <dir>` | `reports` | Output folder for HTML reports |
| `vReport_history` | `--vReport-history <dir>` | `reports/.history` | Directory where historical runs are stored |
| `vReport_xml` | `--vReport-xml <path>` | Auto-detected | Path to JUnit XML input file |
| `vReport_open` | `--vReport-open` | `false` | Automatically open dashboard in default browser |
| `vReport_disable` | `--vReport-disable` | `false` | Disable VelvetReport generation entirely |
| `vReport_capture` | — | `auto` | pytest telemetry capture (`auto` \| `off`) |
| `vReport_embed_max` | — | `2M` | Maximum attachment size to embed as base64 |
| `vReport_email` / `vReport_email_report_enable` | `--vReport-email` | `false` | Generate email-friendly summary (`velvetreport_email.html`) |
| `vReport_server` | `--vReport-server <url>` | `""` | VelvetReport Platform server URL for auto-upload |
| `vReport_token` | `--vReport-token <token>` | `""` | Bearer authorization token for Platform upload |

### Node.js CLI & Programmatic API

```bash
velvet-report generate <junit.xml | dir/> [output-dir] [options]
velvet-report server [--port 4100]
velvet-report clear-history [dir]
velvet-report info
```

#### Node.js CLI Options
| Flag | Default | Description |
|------|---------|-------------|
| `--title <text>` | XML filename | Report title |
| `--history <dir>` | `<output>/.history` | History directory |
| `--open` | `false` | Open the dashboard in default browser |
| `--email` | `false` | Generate email summary (`velvetreport_email.html`) |
| `--server <url>` | `""` | Upload report XML to platform ingestion server |
| `--token <token>` | `""` | Bearer auth token for server upload |
| `--version`, `-v` | — | Print VelvetReport version |
| `--help`, `-h` | — | Show CLI help text |

#### Node.js Programmatic API Options
```javascript
generate(xmlPath, outputDir, {
  title: 'My Custom Suite',     // Report title string
  historyDir: 'reports/.history', // Historical data directory
  open: false,                  // Open browser automatically
  email: true                   // Generate velvetreport_email.html
});
```

---

## Architecture & Local Platform Development

VelvetReport maintains a strict one-way build pipeline:

```text
core/src/template-parts/               ← Modular HTML / CSS / browser runtime
core/src/parser.js                     ← JUnit XML parser
core/src/history.js                    ← History + email
core/packages/python/get_pytest_data/  ← pytest auto-capture plugin
        ↓
node scripts/build.js                  ← Compiles to all 3 platforms + 25 self-tests
        ↓
packages/pip → PyPI   packages/npm → npm   packages/maven → Maven Central
```

### Local Platform Ingestion & Server (Optional)
For team workflows and local aggregation:
```bash
# 1. Start local ingestion server (defaults to port 4100)
node offlineReport/platform/server.js

# 2. Run platform verification tests
npm run test:platform

# 3. Build & verify offline packages
node scripts/build.js --verify
```

Contributing? See [CONTRIBUTING.md](https://github.com/DwivediTarun/offline_velvet_report/blob/main/CONTRIBUTING.md) — small files, `FIX:` headers, easy to extend.

---

## Supported Frameworks

pytest · Playwright · Robot Framework · Jest · Cypress · Mocha · Jasmine · Vitest · Karma · WebdriverIO · JUnit 5 · TestNG · Maven Surefire · Gradle · RSpec · PHPUnit · gotestsum · xUnit · NUnit · and any tool that outputs standard JUnit XML.

---

## Support the Project & Donate

If VelvetReport helps you or your team build and debug faster, please consider supporting the project. Your contributions directly help us maintain the library and reach our target of **10M+ downloads/users**!

[![Buy Me a Coffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-Donate-ffdd00?style=flat-square&logo=buy-me-a-coffee&logoColor=black)](https://buymeacoffee.com/DwivediTarun)
[![Sponsor on GitHub](https://img.shields.io/badge/Sponsor%20on%20GitHub-Donate-ff69b4?style=flat-square&logo=github-sponsors&logoColor=white)](https://github.com/sponsors/DwivediTarun)

- ☕ **[Buy Me a Coffee](https://buymeacoffee.com/DwivediTarun)**: A fast, simple way to show support.
- 💖 **[Sponsor on GitHub](https://github.com/sponsors/DwivediTarun)**: Fund ongoing maintenance and feature development.
- ⭐ **Star the Repository**: Help increase the project's visibility across the developer community.

---

## License

MIT © [Tarun Dwivedi](https://github.com/DwivediTarun) and VelvetReport Contributors.

---

*Keywords: junit xml report generator, html test report, pytest html report, pytest allure alternative, playwright test report, jest html reporter, cypress report, offline html test report, self-contained test report, CI test dashboard, test history tracking, flaky test detection, xdist report, python test report, junit 5 report, maven surefire report*
