Improve Newman Documention for Custom Reports

Hi, I’m not sure if Newman should have its own thread/category so apologies.

I’ve seen several questions in the Slack channel asking about “can Newman can do this…” and the usual response seems to be “No, but you can acheive this by using Custom Reports”

To be honest, I’ve always found this response dismissive, especially with the lack of documentation on the Newman page in regards to custom reports.
I’ve always found Postman to be the perfect tool for non-technical people to start writing code, but I still feel a gap needs filling for users that want to start utilising Newman’s custom reports.

Can we include more documentation on custom reports for Newman and some more user-friendly custom report examples?
Maybe even a Youtube tutorial showing how to output test results for each iteration run (this is something that has been asked A LOT)

7 Likes

Just incase if anyone’s interested, I have the below “nasty-looking” Javascript in a copy of the default HTML Newman Report:

var maxTests = document.getElementsByClassName('total-assertions')[0].innerText
var passValue = document.getElementsByClassName('pass')
var failValue = document.getElementsByClassName('fail')
for(var i = 0; i < maxTests; i++) {
  if (passValue[i].innerText >= 1) {
    passValue[i].style.backgroundColor = "Lime";
  }
    if (failValue[i].innerText >= 1) {
      failValue[i].style.backgroundColor = "Red";
    }
}

This will use the colour “Lime” for all Passes and “Red” for all Failures:

This will at least make it easier to spot failures when scrolling through a HTML report that has lots of assertions.

Feel free to post screenshots of your Newman HTML Reports since there’s NOTHING online xD

1 Like

Sharing across an updated version of the newman template which is colored. Below are the things added to the standard newman template

  1. Updated the default fields in the newman temaplate and removed few fields
  2. Colored the request header based on the pass/fail status. If all test cases inside a request is passed, the request header is considered as passed and colored in green. Even if one is failed, the request will be colored in red to indicate failed
  3. Added a script to dynamically color the overall failed test case count to red. If all test cases have passed, then the color will not change and ‘0’ failed test cases will be shown in red.
  4. Updated the script for the colors in the inner assertions
  5. Updated the request to collapse on initial report load and added a disclaimer to open the request as needed

Please see attachment.

Please share any feedback on this. Thanks!

2 Likes

I love the looks of this @azharmohammedk Can you share the HBS file with us?

This is great, can u share the hbs file?

I am not able to share html or hbs files here. Please slack me in postman community and I will send you the file. Thanks!

I completely agree that we can do a lot more with the documentation of Newman. In fact, all that we know about reporters is cramped into the paragraph in README https://github.com/postmanlabs/newman/blob/develop/README.md#creating-and-using-custom-reporters

I would be super glad if one of our power users can help us getting started. Essentially, the reporter simply is a node module with specific name and constructor interface that is loaded as a run is started and all events are forwarded to it. The events are also documented in readme. In fact, our CLI is a reporter too and is a super easy reference. Also there are two undocumented reporters in the reporters folder that are simple enough for reference.

Hi Guys, can someone please share that hbs file. That is exactly what i was looking for.

Can you please the hbs file for the custom report?

Hey, this might help.

https://www.getpostman.com/docs/postman/collection_runs/command_line_integration_with_newman#custom-reporters

SatejMirpagar https://community.postman.com/u/satejmirpagar - Please
find attached. Thanks.

Sorry mate, I cannot see/download the attachment.

Your template is reaaly good :). Could you please share it ?

it’s very important case. default html template is very dummy, postman runner generates much more informative.
where can be posted feature request for html report upgrade?

Hello ,
This is exactly what we are trying to achieve in our project. Could you please share your template for me to use?
thanks in advance.

I am not able to upload HTML template here. Could you please slack me and I can share? Thanks!

Hi

Could tou pls share steps and code to get colored report in hrml for pass fail to below id
[email protected]

Regards.divya

Hi Azhar , Can you share the HBS file for custom report or any GIT location instead .Thanks

Hi guys,
Here is a colored version of the default-template.hbs, I only closed the details pane by default and colored some informations.

Imgur: The magic of the Internet (sorry, I can only post 1 image as a new member)

For any suggestions, add a comment on the gist page. :slight_smile:

2 Likes

Please find attached the sample HTML file. Thanks!

Regards,

Azhar