Newman htmlextra Report - Customizing

Currently using the newman htmlextra reporter. For Passed test cases the displayed information is sufficient and for failed test case is it possible to add some other details to it while displaying?

Say like for example, in the above screenshot we can add some other details to make it more clear. i.e some details from response body or the endpoint url used so on.

All of those details can be found within the original request in the main view so it would be like replicating that in 2 different areas.

The reporter is run on templates, you are in full control to add/remove any information you like by just creating a new template. :grin:

You would just pass that new template file path in the flag, from the CLI:

--reporter-htmlextra-template newTemplate.hbs

@danny-dainton Thanks Danny!

I can even start editing the default template right?

I tried to pick the same code and tried it before editing. Got the below error:

Please advise on what I am missing.

I have no idea what you changed to even begin to help :smile: - I know what that error is but without even a tiny bit of context, I won’t be able to do/or suggest anything. :smile:

That is a link to the template the reporter uses by default, you could copy that locally and make changes or craft something entirely different. Then pass that on the CLI as your template.

@danny-dainton I am yet to do any changes to the existing script. I copied the HTML code which you have for default report, tried to save it as hbs file and passed it into my command. Once this is successfully I thought of editing the default report to fit in my needs.

What version are you using?

Newman version - 5.1.2
Postman version - 7.31.1

The htmlextra reporter version - The latest is 1.19.0 which will work with that template but earlier versions might not.

Doing an npm update newman-reporter-htmlextra or npm update -g newman-reporter-htmlextra depending where you’re using the reporter should update it to the latest version.

2 Likes

Hi @danny-dainton thanks for your work with this stellar reporter!
Following I’d like to catch up this one.

As an constant beginner I would like to know how to create my own template.
Can I export the default template or where can I find this or can you link here the respective information?

Cheers, M

Found this here:

1 Like

Hey @martin4 :wave:

This reporter, by default, uses this template - You can copy this and create a new template. Ensure that you save this with the .hbs file extension.

To run your custom template with the reporter - you can use:

newman run collection.json -r htmlextra --reporter-htmlextra-template filepath/your-custom-template.hbs

I wrote this a couple of years ago to explain, in a basic way, how to create a template:

2 Likes

hi @bpricilla have you customized the .hbs template and the index.js file.

Which type of change are you looking to make?

The template file (.hbs) would be something that you can use on your side, to display anything on the report, in a way that you want.