skip to content

Which reporters ship with Newman's `-r` option, and how does it resolve a name that is not built in?

level: middleimportance: must knowfreq 68%

answer

  1. Five bundled, everything else is a package
  2. A naming convention, not a registry
  3. Scoped packages keep the scope in front
  4. The external lookup is tried first
  5. A missing reporter only warns

basics

~10 s

Newman ships five reporters: cli, json, junit, progress and emojitrain. Any other name given to -r is required as the package newman-reporter-<name>, so -r html loads newman-reporter-html; a scoped name becomes @scope/newman-reporter-name.

solid answer

~40 s

The five reporters bundled in Newman's own source are `cli`, `json`, `junit`, `progress` and `emojitrain`. For every name in the `-r/--reporters` list, Newman first tries `require('newman-reporter-' + name)` — a scoped `@acme/foo` becomes `@acme/newman-reporter-foo` — and only when that `require` throws does it fall back to the bundled map. So an installed external package can shadow a built-in name. If neither resolves, Newman prints `could not find "<name>" reporter` as a warning and **the run continues**; a missing reporter never fails the build. Per-reporter settings arrive as `--reporter-<name>-<option>`, and `--reporter-<option>` applies to every reporter in the list. `newman-reporter-htmlextra` appears in Newman's documentation but ships nowhere in its source — treat it as external.

code

bash · 4 lines
bash
newman run ./collection.json \
  --reporters cli,junit \
  --reporter-junit-export ./reports/junit.xml \
  --reporter-cli-no-banner

go deeper

for a junior

Learn the five names that ship — cli, json, junit, progress, emojitrain — and that -r takes them as a comma-separated list with no spaces. Know that cli is what prints the familiar summary.

for a middle

Explain the resolution mechanics: the newman-reporter-<name> package convention is tried first, the bundled map is the fallback, and a name that resolves to neither produces a warning rather than a failure.

for a senior

Demonstrate that report production is not guaranteed by a green run. Show how you verify the artifact exists, why you name cli explicitly beside a file reporter, and why two terminal reporters interleave badly.

for a principal

Weigh depending on a third-party reporter against writing one in-house. An external package is another upgrade surface loaded into the same process; an in-house reporter is code your team must keep working.

## What `-r` actually selects `-r, --reporters` takes a comma-separated list — no spaces around the commas — and the option's default value is `['cli']`. The value is produced by splitting the supplied string, so passing the option **replaces** the default rather than adding to it. Each name in the resulting list is turned into a reporter *constructor*, which Newman then instantiates as `new Reporter(emitter, reporterOptions, options)`. A reporter is therefore just an object that subscribes to the run's events; nothing about a reporter changes what is sent or what passes. ## The five that ship in the box | Name | What it produces | Default file when no export path is given | |---|---|---| | `cli` | the running assertion log and the summary tables in the terminal | none — it writes to the terminal | | `json` | the run summary serialised as JSON | `newman-run-report.json` | | `junit` | an XML report built from the run's executions | `newman-run-report.xml` | | `progress` | a single progress bar advancing once per item | none — it writes to the terminal | | `emojitrain` | one emoji per item, happy or sad | none — it writes to the terminal | That list is exhaustive: those five are the only reporters present in Newman's own source. Everything else is a separate package. ## How a name becomes a module For each name in the list, in order: 1. Newman builds a package name by the **`newman-reporter-<name>` convention** and `require`s it. A scoped name is handled by moving the scope to the front: `@acme/teamcity` is loaded as `@acme/newman-reporter-teamcity`. 2. If that `require` throws, Newman falls back to the bundled map and uses the built-in of that name, if one exists. 3. If neither resolves, it warns — `newman: could not find "<name>" reporter`, plus a reminder that the reporter must be installed in the same directory as Newman — and moves on. 4. If a reporter is found but its constructor throws, Newman warns `could not load "<name>" reporter`, prints the error, and still continues. Two consequences follow, and both surprise people: - **The external lookup happens first.** Installing a package literally named `newman-reporter-cli` beside Newman would shadow the built-in `cli`. Resolution is external-first, built-in-second. - **A missing or broken reporter never fails the run.** The requests still go out, the assertions still run, and the exit code is decided by the run's failures — not by whether your report was produced. A pipeline that depends on a report file must check for the file itself. ## Options for one reporter or for all of them Reporter settings are passed as prefixed options, which Newman strips out of the argument vector before `commander` parses it, then re-parses on its own: - `--reporter-<name>-<option>` targets one reporter: `--reporter-cli-no-banner`, `--reporter-junit-export ./reports/junit.xml`. - `--reporter-<option>` with no reporter name is generic and is merged into **every** reporter's options: `--reporter-silent` quiets all of them at once. - A prefixed option with no value becomes boolean `true`; the rest of the name is camel-cased, so `--reporter-cli-no-summary` reaches the `cli` reporter as `noSummary`. ## Dominant reporters Three of the built-ins mark themselves **dominant**: `cli`, `progress` and `emojitrain`. All three write to the terminal, and two of them would fight over the same lines. When more than one dominant reporter ends up in the list, Newman warns `<a>, <b> reporters might not work well together` — a warning, again, not an error. `json` and `junit` write files and are not dominant, which is why pairing one of them with `cli` is the ordinary combination. ## The name that is documented but not shipped `newman-reporter-htmlextra` shows up in Newman's own documentation, and many teams assume it is bundled. It is not present anywhere in Newman's source. The same is true of `newman-reporter-html` and `newman-reporter-teamcity`, both of which Newman knows well enough to print an install hint for when the name is missing — that hint is exactly the evidence that they live outside the package. Assert the five built-ins and describe everything else as an external package resolved by the naming convention. ## Checklist for a real command - Name `cli` explicitly whenever you add another reporter, or you lose the terminal output. - Give any file-writing reporter an export path, or the file lands somewhere you did not choose. - Do not pair two dominant reporters unless you enjoy interleaved output. - Verify the report file exists after the run; a warning about a missing reporter will not stop the pipeline for you.

  • You pass a reporter name that is not installed anywhere. What does the run do?
    It warns and carries on. Newman prints `could not find "<name>" reporter` plus a note that the reporter must be installed alongside Newman, then runs the collection normally. The exit code still reflects assertion and script failures only, so a pipeline that needs the report has to check for the output file itself.
  • Which built-in reporters conflict with each other, and how does Newman signal that?
    `cli`, `progress` and `emojitrain` are each flagged dominant because all three write to the terminal. If more than one dominant reporter ends up in the list, Newman prints a warning that those reporters might not work well together. It is only a warning — the run proceeds and the output interleaves.
  • How would a reporter you write yourself be found by name?
    Publish or install it under the `newman-reporter-<name>` package name beside Newman, then pass the bare `<name>` to `-r`. The module must export a constructor, which Newman calls with the run emitter, that reporter's own options, and the generic run options; it subscribes to whichever run events it needs.

saying these in an interview costs you the question

  • Names htmlextra among the reporters shipped with Newman
  • Thinks a missing reporter package fails the run
  • Believes built-in names are checked before external packages
  • Passes the full package name to -r instead of the short name
  • Assumes adding a reporter keeps the terminal output
  • Thinks a reporter can change which assertions pass