Skip to content

Newman Reporters — Generating Detailed API Test Reports from Newman Runs

DodaTech Updated 2026-06-28 1 min read

In this tutorial, you will learn about Newman Reporters. We cover key concepts, practical examples, and best practices to help you master this topic.

Newman reporters transform collection run results into structured output formats — CLI output, JSON dumps, JUnit XML for CI integration, detailed HTML reports, and custom formats for team dashboards.

Code Example: Using Multiple Reporters

# CLI + JUnit + HTMLExtra reporters
newman run threat-api-collection.json \
  --reporters cli,junit,htmlextra,json \
  --reporter-junit-export reports/junit-results.xml \
  --reporter-htmlextra-export reports/html-report.html \
  --reporter-json-export reports/raw-results.json

# TeamCity reporter for JetBrains CI
newman run threat-api-collection.json \
  --reporters cli,teamcity

# Custom reporter
newman run threat-api-collection.json \
  --reporters cli,custom-reporter \
  --reporter-custom-reporter-option key=value

Code Example: Programmatic Report Processing

const newman = require("newman");
const fs = require("fs");

newman.run({
    collection: require("./threat-api-collection.json"),
    reporters: ["cli", "json"],
    reporter: {
        json: { export: "./results/raw.json" }
    }
}, function (err, summary) {
    if (err) throw err;

    const run = summary.run;
    const stats = run.stats;
    const failures = run.failures;
    const timings = run.timings;

    // Generate custom summary report
    const report = {
        timestamp: new Date().toISOString(),
        duration: timings.completed - timings.started,
        environment: summary.environment?.name || "unknown",
        collection: summary.collection?.info?.name || "unknown",
        stats: {
            total: stats.assertions.total,
            passed: stats.assertions.passed,
            failed: stats.assertions.failed,
            skipped: stats.assertions.pending || 0
        },
        failures: failures.map(f => ({
            source: f.source.name,
            test: f.error.test,
            message: f.error.message,
            at: f.at
        })),
        responseTimes: {
            min: stats.responses.min,
            max: stats.responses.max,
            avg: stats.responses.mean,
            median: stats.responses.median
        }
    };

    fs.writeFileSync(
        `./reports/summary-${Date.now()}.json`,
        JSON.stringify(report, null, 2)
    );

    // Calculate pass rate
    const passRate = (stats.assertions.passed / stats.assertions.total) * 100;
    console.log(`Pass rate: ${passRate.toFixed(1)}%`);

    // Fail if below threshold
    if (passRate < 95) {
        process.exit(1);
    }
});

Common Mistakes

1. Not Installing Reporters Globally

HTMLExtra and custom reporters must be installed: npm install -g newman-reporter-htmlextra. Missing reporters cause silent fallback to CLI only.

2. Reporter Export Path Issues

Export paths are relative to the working directory. Use absolute paths in CI: --reporter-junit-export $CI_PROJECT_DIR/reports/junit.xml.

3. Timeouts in HTML Reports

HTMLExtra includes response time charts. Timeout values above 30 seconds may not display correctly. Adjust chart settings in HTMLExtra config.

What's Next

Now learn about Supertest for Node.js Deep Dive for programmatic API testing in JavaScript.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro