musaffir
(musaffir)
September 28, 2018, 3:37am
1
Hello,
I found debugging through collections, pre-request scripts etc are not very easy in Postman.
More details on it can be found in this feature request i saved -
opened 05:40AM - 26 Sep 18 UTC
feature
console
product/runtime
Hello,
**Is your feature request related to a problem? Please describe.**
Ye… s,
I do have a collection which is relatively a larger one with many requests and many Tests
I often run them either using postman Runner fetaure, or with Newman cmd tool
I do have some testing functions written at **pre-request scripts** tab of the Collection or at a particular folder level.
I tried to make this pre-request scripts in such a way that, I write it only once at Collection or Folder level, then I re-use/invoke the same js functions at **Tests** tab of individual request endpoints present in the Collection.
I do come across some issues with the api endpoints sometimes due to various reasons that it do not return a response content or in other words give a empty body etc. And the functions that I invoke are called with these response arguments.
Now sometimes those functions will not work as expected because the passed argument could be of empty or something . (The issue could be something like, I have a empty response, and in the common function if I try to parse it to JSON format , it will give JSON exception, I could have handled it any way at the functiona definition level, but thats not the issue am trying to say here)
and in such situations the Postman will give notification that "**Something went wrong while running your scripts. Check Postman Console for more info.**"
Looking at the console will only give some idea about what is the issue
It do not give idea on where exactly the issue had happened
i.e it do not give a stack trace kind of information
So its some times bit difficult / time consuming for me to identify where exactly in the script/function the isssue is happening in order to fix them or take action. One good thing is the console at lease give idea on under what request hit the issue had happen.
**Describe the solution you'd like**
Better debuggin facility
Trace of errors in the console window
**Describe alternatives you've considered**
Putting console.log in the script, but that looks not good for me.
Eventually I do not need many console.log in my script, and i will have to clean them up once i traced down the issue
**Additional context**
Please find the screenshot of information in the current console window
![postman console](https://user-images.githubusercontent.com/25841256/46059398-afe15900-c191-11e8-96ce-f6a534695fde.png)
Would like to get suggestion from our community, whether you come across this situation and how you manage this
Thanks & Warm Regards
Musaffir
ankit-m
(Ankit Muchhala)
October 3, 2018, 4:43pm
2
Have you tried running the collection via a CLI using newman
? You will get all the errors in one place.
Newman - https://learning.getpostman.com/docs/postman/collection_runs/command_line_integration_with_newman/#___gatsby
musaffir
(musaffir)
October 4, 2018, 2:25am
3
Hi @ankit-m
Thanks for the reply
Yes I do run using Newman, but that something I use to execute the collections once its built and ready to integrate with the CI workflow
As we all do, I also depend on the postman gui tool for all the collection development and test runs etc
So i was looking for how better I can debugg collection, pre-request scripts etc with in postman gui tool
I will see how Newman is helpful to me in this regard, and its giving useful clues on script errors/exceptions etc
Thanks
Musaffir
musaffir
(musaffir)
October 4, 2018, 3:15am
4
Hi @ankit-m
I quickly check this.
I think the latest version of newman (4.1.0) is a little better than the previous one,
and I see the html-reporter is separated and it has its own dependency to generate html type of report ( newman-reporter-html) . Here i get a separate failure section as you mentioned .
That was not the case with previous Newman (3.9.4)
Thanks,
1 Like