Using package-library functions

I am starting to use Package Library and defining functions in the library according to this article - Reuse scripts in Postman | Postman Docs
So far so good.
One thing I find cumbersome and repetitive is the step to import the package in each and every one of my requests with a const package = pm.require('…") and I was trying to see if I can do the import step at the collection level so that the package variable is available in all of my requests for that collection (or folder). I searched documentation but all I could find is references to using global functions and doing an eval in each request to request the global function (which is no different than doing an import in every request).

Is this capability possible?

Thanks

Hi @csc-ganesh-kumar,

I know what you mean, I’ve seen where I need a function in a pre-requests and test I need to load it twice, which seems inefficient.

I suppose they are sandboxed so they can’t be shared easily between the areas.

Hopefully, it can be improved over time, I use it with Posman CLI and see the module being loaded on every test.

Before the package library was developed, I used to add my shared functions to the Collection and could reference them anywhere in that collection. But then I had to copy and paste them around each collection that needed them, which wasn’t ideal. So it’s heading in the right direction :slight_smile: