GitHub

CSV Exporter

Export filtered test runs, metrics, and regression datasets to standard CSV files with dynamic contextual naming.

Zen Reports provides client-side CSV export across tabular views in the dashboard. Rather than providing a generic download, the exporter generates contextual, standard-compliant CSV spreadsheets reflecting active search filters, date ranges, and execution run identity.

Export CSV button on the per-file table
The Export CSV button in action on the Files breakdown view.

Core Principles

  • Zero-Roundtrip Client Execution: Exports are generated directly in the browser via Blob URLs and programmatic download anchors. No test data, stack traces, or metrics are uploaded to external APIs or conversion services.
  • Full Filtered Dataset Scope: The exporter captures all records matching your current filter criteria—not just the rows currently visible on page 1 of the paginated table.
  • RFC 4180 Compliance: All fields containing commas, line breaks, or quotation marks are escaped and quoted, ensuring clean ingestion into spreadsheet tools like Microsoft Excel, Google Sheets, LibreOffice Calc, or business intelligence pipelines.
  • UTF-8 Encoding with BOM: Text data is exported with a Byte Order Mark (\uFEFF) so non-ASCII characters, special test symbols, and emojis render correctly in spreadsheet editors without character scrambling.

Supported Dashboard Surfaces

The Export CSV action is integrated into key data views throughout the report:

View / Surface Table Content Exported Fields
Files Per-spec-file breakdown File path, total tests, passed, failed, flaky, skipped, duration (ms), failure rate
History (Runs) Historical execution runs Run ID, run name, branch, commit SHA, start time, total tests, pass rate, duration
History (Tests) Historical test stability Test title, spec file, project, total executions, pass count, flaky count, failure count
Insights (Flaky) Flaky test rankings Test title, spec file, project, retry rate, occurrences, last flaky run date
Insights (Slow) Top slow test executions Test title, spec file, project, duration (ms), execution status, run date
Insights (Errors) Failure cluster distribution Error message signature, category, affected test count, percentage of run failures
Trends (Tables) Collapsible historical metrics Run name, date, pass rate, project durations, step category timing breakdowns

Dynamic File Naming Conventions

The exporter constructs suggested filenames by combining the active view or metric type, applied date or search filters, the viewed execution run name, and a local timestamp (YYYY-MM-DD_HHmm).

This ensures multiple exports saved to your local downloads folder stay organized and recognizable without manual renaming.

Example Generated Filenames

Scenario / Scope Selected Filter Search Query Generated Filename
Preset Date Filter Last 30 Days None flaky-tests_last-30-days_2026-10-05_1430.csv
Single Month Range October 2026 None flaky-tests_october-2026_2026-10-05_0915.csv
Custom Multi-Month Range 2026-08-01 to 2026-10-05 None flaky-tests_2026-08-01-to-2026-10-05_2026-10-05_1845.csv
Combined Search & Preset Last 30 Days "login" test-runs-history_last-30-days_search-login_2026-10-05_1105.csv
Search Term Filter None "auth" test-regressions_search-auth_2026-10-05_1520.csv
Active Run Name Tag (File Summary) Run: nightly-build-102 None file-summary-metrics_nightly-build-102_2026-10-05_1430.csv
Combined Search & Run Name (File Summary) Run: nightly-build-102 "login" file-summary-metrics_search-login_nightly-build-102_2026-10-05_1430.csv
Spec File History with Date Range & Search Last 14 Days "auth" spec-file-history_last-14-days_search-auth_2026-10-05_1640.csv
Test Case History with Date Range Last 7 Days None test-case-history_last-7-days_2026-10-05_1200.csv
Default / Unfiltered Dataset None (All runs) None slowest-tests_2026-10-05_1430.csv
Trend Metrics (Pass Rate / Duration / Steps) None (Aggregated) None pass-rate-trend_2026-10-05_1430.csv

Filtering, Pagination, and Search Scope

When exporting data, the utility observes the following rules:

  1. Search Query Active: If text is entered into the table search box (for example, searching "checkout"), only tests or files matching that term are included in the export, and search-<term> is reflected in the filename.
  2. Status Dropdowns Applied: If you filter the Files or Suites view to show only Failed or Flaky items, the exported CSV mirrors that exact subset.
  3. Cross-Page Completeness: If a filtered search produces 120 matching records displayed across 12 pages of pagination, clicking Export CSV outputs all 120 records into a single CSV file.

Automated CLI Exports (zr history)

In addition to the interactive dashboard buttons, the companion CLI tool (zr) provides automated headless CSV exports designed for CI/CD pipelines, pull request comment bots, and automated health checks:

Exporting Predefined History Views

Pass the --export (or -e) flag to any zr history subcommand:

Terminal window
# Export all flaky tests to an auto-named CSV file
npx zr history flaky --export
# Export top 50 slowest tests directly to a custom file
npx zr history slow --limit 50 --export slow-tests.csv
# Export run stability trends
npx zr history runs --export ci-runs.csv

Exporting Custom DuckDB Queries

Run arbitrary SQL queries against your test run history and pipe the results directly to CSV:

Terminal window
npx zr history query "SELECT test_id, title, file_path, retry_count FROM tests WHERE status = 'flaky'" --export flaky-audit.csv

For more details on CLI capabilities, refer to the CLI History & Analytics guide and Custom SQL Queries.