# How do you debug your collections, pre-request script, test scripts etc

**URL:** <https://community.postman.com/t/how-do-you-debug-your-collections-pre-request-script-test-scripts-etc/2813>\
**Category:** Help Hub\
**Created:** [September 28, 2018, 3:37am UTC](https://community.postman.com/t/how-do-you-debug-your-collections-pre-request-script-test-scripts-etc/2813 "2018-09-28T03:37:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![musaffir](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@musaffir](https://community.postman.com/u/musaffir)\
**Post date:** [September 28, 2018, 3:37am UTC](https://community.postman.com/t/how-do-you-debug-your-collections-pre-request-script-test-scripts-etc/2813/1 "2018-09-28T03:37:11Z")

</div>

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 -

> <https://github.com/postmanlabs/postman-app-support/issues/5252>
>
> 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

---

<div class="post-metadata">

**Author:** ![ankit-m](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/ankit-m/32/979_2.png) [@ankit-m](https://community.postman.com/u/ankit-m)\
**Post date:** [October 3, 2018, 4:43pm UTC](https://community.postman.com/t/how-do-you-debug-your-collections-pre-request-script-test-scripts-etc/2813/2 "2018-10-03T16:43:54Z")

</div>

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](https://learning.getpostman.com/docs/postman/collection_runs/command_line_integration_with_newman/#___gatsby)

---

<div class="post-metadata">

**Author:** ![musaffir](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@musaffir](https://community.postman.com/u/musaffir)\
**Post date:** [October 4, 2018, 2:25am UTC](https://community.postman.com/t/how-do-you-debug-your-collections-pre-request-script-test-scripts-etc/2813/3 "2018-10-04T02:25:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![musaffir](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@musaffir](https://community.postman.com/u/musaffir)\
**Post date:** [October 4, 2018, 3:15am UTC](https://community.postman.com/t/how-do-you-debug-your-collections-pre-request-script-test-scripts-etc/2813/4 "2018-10-04T03:15:57Z")

</div>

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,
