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
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 ) in the respective path…
So that request and response body can be seen in Report generated and HTML report shows results for all Iterations.
Still some more improvisations are needed, any help is much appreciated
Sample :
This is cool. Thanks @gopikrishna4595!!
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
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
Hi @gopikrishna4595 , I followed your thread with postman/newman support member and implemented cusotm report in my project. Somehow I am not getting the colored pattern, can you please share your hbs file here (i dont have access to google drive from office, so appreciate if you can paste it here…many thanks
Hi… just a quick think…did u change the index.js file ?
Hi @gopikrishna4595
Got ur latest updates… checked with new index.js and .hbs files, previously reported issue of not displaying request/response body for alternate service requests has been fixed, it looks good. Newly added glyphicons looks pretty. Great team work all of u… thank u so much…ur efforts are appreciated much…
Hi all,
Ah! Yes, It was late, Sorry for the delayed response due to Fifa preparations ,
Fixed the errors &
The response body will be in Pretty Format for both Json and Xml bodies. added some glyphicons too
Below are the latest index.js and .hbs files,
Latest Postman Files
includes the efforts and Credits: @rmlira @azharmohammedk @tegomassria @postman-paul540
Still some more improvisations are needed, any help is much appreciated
Hi Gopikrishna,
Thanks for sharing me the files.
I am using node version- 8.11.2 and Newman version - 5.6.0.
I can’t find any Report folder so How can I use this files index.js and .hbs files to generate report?
Thanks
Hi @bincygijo
replace your existing files with the shared ones in your PC at this location :
C:\Users\gopikrishna4595\AppData\Roaming\npm\node_modules\newman\lib\reporters\html