Improve Newman Documention for Custom Reports

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
Divibhat.ramesh@gmail.com

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.

https://imgur.com/a/9ygS9 (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

I have a hard time to locate this file “default-template.hbs
Is someone can direct me or help me to find it
Thanks

as this post is mostly viewed and counting
Posting here, So that it may reach to more who needs…

Have to edit template-default.hbs and index.js you will need to access the folder node_modules/newman/lib/reporters/html

In template-default.hbs

inside block {{#*inline “aggregations”}} {{#each executions}} and after the {{#with request}} block, add a ‘div’ with ‘{{response.body}}’ this will make handlebars iterate over each executions in json result and print the response.body data inside a div.

Using {{response.body}} outside the {{#with request}} helps to get a response in the report.

when collection is run with iteration, HTML report only shows results for first Iteration

This problem occurs because in template it creates a div.panel-group for each execution, and the id attribute of this div is ‘collapse-request-{{item.id}}’. This way, for each iteration it will create n new div’s with same id, because item.id is the same in each iteration… this causes javascript to not work properly. When you click in a div it navigates throw DOM to find the first panel that must expand/collapse with the target id, as div’s has same id it always will use only first div. (https://getbootstrap.com/docs/3.3/javascript/#collapse)

To fix this, we should increment the id attribute with index of iteration… handlebars has a builtin helper that brings the index to us.

On template in block:

{{#*inline “aggregations”}}
{{#each executions}}

you must find each ‘{{item.id}}’ and replace then with ‘{{item.id}}-{{@index}}’, this way we guarantee that each div has a unique id, and javascript could work properly.

To that, you need to modify index.js file…

you will need to access the folder node_modules/newman/lib/reporters/html in this folder there’s an index.js file, you need to edit this file to make it works properly on iterations.

The problem occurs because it considers only ‘currentExecution.id’ when aggregating data, we need it to consider currentExecution.id and currentExecution.response.id… cause our execution.id is the same but response is not. In order to do this you will need to replace multiple lines in file as follows:

line ~65:
executionId = currentExecution.id;
replace with:
executionId = currentExecution.id + currentExecution.response.id;

line ~92:
items[reducedExecution.item.id] = reducedExecution;
replace with:
items[reducedExecution.item.id + reducedExecution.response.id] = reducedExecution;

line ~126 and ~127:
current = _.merge(items[execution.item.id], {
assertions: _.values(assertions[execution.item.id]),
replace with:
current = _.merge(items[execution.item.id + execution.response.id], {
assertions: _.values(assertions[execution.item.id + execution.response.id]),

line ~132:
cumulativeTests: netTestCounts[execution.item.id]
replace with:
cumulativeTests: netTestCounts[execution.item.id + execution.response.id]

this will make it works with iterations, you can try this modifications in your own risk, in any case just restore the original index.js file.

Credits: @rmlira

Original Post:
How to capture response body data in Newman result report

Still some more improvisations are needed, any help is much appreciated :grinning:

Sharing the Files with the above mentioned Changes

Keep a copy of original files some where on your local disk, and replace them with the files(sharing via Google Drive :point_down: ) in the respective path…

So that request and response body can be seen in Report generated and HTML report shows results for all Iterations.

Google Drive Link

Still some more improvisations are needed, any help is much appreciated :grinning:

Sample :

1 Like

This is cool. Thanks @gopikrishna4595!! :slight_smile:

Hello,

I’m using a customized template for Newman.
There is a way to show at first position the test suite where there are failed test?
For example in this case I want to show first “AXON” and after “LOGIN”
I don’t kwnow how to access to parent.failedtest in each agreggation


Thank you,

Thanks gopi… this is awesome, this is really helpful…i referred the shared files and tried couple of scenarios. Report looks great. I have 4 requests for each iteration and totally 9 iterations, i am able to expand the request body and response body only for alternate requests (2nd and 4th requests) in each iteration. I am using internet explorer browser. Could you help on this, it would be good to know how to fix it. Thanks again.

yeah, i observed the same @sethuchiyan16.

Will check where it went wrong and let you know once done.

@gopikrishna4595 Thanks Gopi…

Hi gopi…may i know if there is any update… thank u.

Hi @sethuchiyan16,
Found the root cause for the issue,
it was due to the collapsible class in that div/pre. Working on the fix.

Thanks Gopi for the update…Great.

Hi everyone,

I have a scenario where I do multiple iterations and I also use the setNextRequest method in every iteration. What happens now in the html is that in every panel only the first url is shown. (The same request url is therefore displayed in all panels, while each time this changes per request). Also all tests results of all requests are displayed in each panel. Not the test from that specific request. I try to show what I mean by a number of photos. I hope someone haves a solution for this, its hard to explain as you can see :slight_smile:
Any questions? pls ask

Hi Guys… i have applied the given HBS file but I am not able to get this layout…I can see only traditional black n white report