newman-reporter-htmlextra

newman-reporter-htmlextra

A Newman HTML reporter that has been extended to include the separation of the iteration runs so these are no longer aggregated together and also some additional handlebars helpers to enable users to create better custom templates. This reporter comes with a default dashboard style template and also a Dark Theme version that can be switched using a CLI flag.

Some of the Extras

Full separated iterations runs and not aggregated stats - Default template shows iteration number in heading

Options

With Newman CLI

Specify a path where the output HTML file will be written to disk. If not specified, the file will be written to newman/ in the current working directory.

--reporter-htmlextra-template <path>

Specify a path to the custom template which will be used to render the HTML report. This option depends on --reporter htmlextra and --reporter-htmlextra-export being present in the run command. If this option is not specified, the default template is used

--reporter-htmlextra-showOnlyFails

Use this optional flag to tell the reporter to display only the requests with failed tests.

--reporter-htmlextra-darkTheme

Use this optional flag to switch the reporter template to the Dark Theme dashboard.

--reporter-htmlextra-testPaging

Use this optional flag to add pagination to the tests in the request view.

--reporter-htmlextra-title

This optional flag can be used to give your report a different main Title in the centre of the report. If this is not set, the report will show "Newman Run Dashboard".

Custom templates (currently handlebars only) can be passed to the HTML reporter via --reporter-htmlextra-template <path> with --reporters htmlextra and --reporter-htmlextra-export.
The default template is used in all other cases.

To create a report that only shows the requests with Failed tests, from the CLI, the following command can be used:

With Newman as a Library

All the CLI functionality is available for programmatic use as well within a nodejs script.

constnewman=require('newman');

newman.run({

collection:require('./examples/Restful_Booker_Collection.json'),// can also provide a URL or path to a local JSON file.

environment:require('./examples/Restful_Booker_Environment.json'),

reporters:'htmlextra',

reporter:{

htmlextra:{

export:'./<html file path>',// If not specified, the file will be written to `newman/` in the current working directory.

template:'<template path>'// optional, the default template will be used if one is not specified

}

}

},function(err){

if(err){throw err;}

console.log('collection run complete!');

});

Add the showOnlyFails property to the htmlextra object, to create a report showing only requests with test failures.

constnewman=require('newman');

newman.run({

collection:require('./examples/Restful_Booker_Collection.json'),// can also provide a URL or path to a local JSON file.

environment:require('./examples/Restful_Booker_Environment.json'),

reporters:'htmlextra',

reporter:{

htmlextra:{

export:'./<html file path>',// If not specified, the file will be written to `newman/` in the current working directory.

showOnlyFails:true// optional, tells the reporter to create a report showing only the requests with failed tests.

}

},function(err){

if(err){throw err;}

console.log('collection run complete!');

});

To use the dark theme template within a script - Add the darkTheme property to the htmlextra object. If the template option is also part of the object, this will overwrite the darkTheme option.

constnewman=require('newman');

newman.run({

collection:require('./examples/Restful_Booker_Collection.json'),// can also provide a URL or path to a local JSON file.

environment:require('./examples/Restful_Booker_Environment.json'),

reporters:'htmlextra',

reporter:{

htmlextra:{

export:'./<html file path>',// If not specified, the file will be written to `newman/` in the current working directory.

darkTheme:true// optional, tells the reporter to use the `Dark Theme` template

}

}

},function(err){

if(err){throw err;}

console.log('collection run complete!');

});

Add the title property to the htmlextra object, to pass in your own custom title to the report.

constnewman=require('newman');

newman.run({

collection:require('./examples/Restful_Booker_Collection.json'),// can also provide a URL or path to a local JSON file.

environment:require('./examples/Restful_Booker_Environment.json'),

reporters:'htmlextra',

reporter:{

htmlextra:{

export:'./<html file path>',// If not specified, the file will be written to `newman/` in the current working directory.

title:'My new report title'// optional, tells the reporter to use this as the main title in the centre of the report

}

}

},function(err){

if(err){throw err;}

console.log('collection run complete!');

});

Default Dashboard

Dark Theme Dashboard

Show Only Failures

If you have mulitiple requests in your collections the report can become quite verbose, I've added a flag option to just create the report with only the requests that have Failed tests. This is very similar to the default report but the folders will already be expanded, if their are any failed tests.

Add the darkTheme flag to see this in the dark view.

Console Logs

This is the first attempt to expose any console.log statements that are really useful to have in your Requests. The event from Newman doesn't contain a lot of detail about the request that it was part of and this will involve, in it's current state a horrible hacky fix to map things together. In the meantime, the Postman pm.info function provides these for you and can just be added to the console.log statement, as workaround. Something like ${pm.info.requestName} | ${pm.info.eventName} | Iteration: ${pm.info.iteration + 1} will log out the missing event information.

If the collection contains Console Logs, a new tab will appear, that will show all the details. This information is displayed in a similar way that you may have seen on the Failed Tests and Skipped Tests.

Compatibility

newman-reporter-htmlextra

newman

node

>= v1.1.0

>= v4.2.3

>= v8.x

Community Support

If you are interested in talking to the Postman team and fellow Newman users, you can find us on our Postman Community Forum. Feel free to drop by and say hello. You'll find us posting about upcoming features and beta releases, answering technical support questions, and contemplating world peace.

Sign in using your Postman account to participate in the discussions and don't forget to take advantage of the search bar - the answer to your question might already be waiting for you! Don’t want to log in? Then lurk on the side-lines and absorb all the knowledge.

License

This software is licensed under Apache-2.0. Copyright Postdot Technologies, Inc. See the LICENSE.md file for more information.

Special mention

This work have been hugely inspired and copied several aspects of the great work done by Martijn Vander Vlag to create the newman-reporter-htmlfull package. Check out that package too, this contains many of the same features.

It was also brought together by reviewing some of the feature requests, for the official Postman HTML reporter.