Use Newman external and custom reporters
Generate reports for your collection runs in Newman with custom and external reporters. You can generate reports for specific use cases, for example, logging the response body when a request or test fails. Use existing external reporters to generate reports, or build your own custom reporters.
Build custom reporters
A custom reporter is a Node.js module with a name in the format newman-reporter-<name>.
To create a custom reporter, do the following:
-
In the directory of your choice, create a blank npm package with
npm init. -
Add an
index.jsfile that exports a function in the following format: -
To use your reporter locally, use
npm packto create a TGZ file. This can be installed usingnpm i -g newman-reporter-<name>.<version>.tgz. Learn more about using custom reporters.Scoped reporter package names like
@myorg/newman-reporter-<name>are also supported. -
(Optional) You can publish your reporter to npm using
npm publish.
Use external and custom reporters
You must install an external or custom reporter to use it. For example, to use the Newman HTML reporter, install the reporter package:
You can use external reporters with Newman if the reporter works with Newman’s event sequence. To learn more, view examples of how Newman reporters work.
The name of the package follows the format newman-reporter-<name>, where <name> is the name of the reporter. The installation is global if Newman is installed globally, and local otherwise. Run npm install ... with the -g flag for a global installation.
To use local (non-published) reporters, run the following command:
You can use the installed reporter either with the command-line tool or programmatically. In either case, the newman-reporter prefix isn’t required while specifying the reporter name in the options.
On the command line:
Programmatically:
Scoped reporter packages must be specified with the scope prefix. For example, if your package name is @myorg/newman-reporter-name, you must specify the reporter with @myorg/name.
The reporter options used in these examples are optional.