Newman: Feature Request: custom JS library/module in tests sandbox

Created on 20 Oct 2014  Â·  15Comments  Â·  Source: postmanlabs/newman

It would be very useful to develop test verification functions, or more elaborate test fixtures to be made available to tests. Because tests are executed in their own vm sandbox, right now there is no way to pass in global functions/objects. Global variables are limited to JSON, but one wants function. In Postman this is achieved by putting such global functions in a pre-tests sections of an empty test, though that may be just a side-effect of how environments are managed in Postman. In any case, the libraries available by default are great, but one always has some custom code that helps structure larger test suites.

Is this something being considered? Would you be receptive to a pull request implementing such a feature and if so, any opinion on how you would like this done (or how would you _not_ like it done :) ?

deferred duplicate feature request tracked

Most helpful comment

Postman/newman was checking all the boxes for rest api automation and then I hit this issue (i.e. not allowing to import custom js) this would be such a useful feature and in my opinion complete Postman.

All 15 comments

Hi @bolerio,
We're working on a way to use custom JS files in the sandbox, both in Postman and in Newman. Will keep you posted on this.

Thank you. I'd appreciate any updates on that!

On Wed, Nov 5, 2014 at 5:14 AM, Abhijit Kane [email protected]
wrote:

Hi @bolerio https://github.com/bolerio,
We're working on a way to use custom JS files in the sandbox, both in
Postman and in Newman. Will keep you posted on this.

—
Reply to this email directly or view it on GitHub
https://github.com/a85/Newman/issues/153#issuecomment-61785697.

https://plus.google.com/+BorislavIordanov

"Damn! The world is big!"

-- Heleni Daly

+1

We're working with JWT (client generated) tokens. We build and included a lib to handle this, but changes need to be done each time postman has been updated.

Would you prefer a PR with JWT as an auth method like here https://github.com/a85/POSTMan-Chrome-Extension/pull/839 ?

+1
@abhijitkane Any updates on this? Timeline, roadmap, etc? I'm wanting to switch all of our projects to postman and this is a huge need for our very large test suites.

The workaround I've developed adds too many layers of complexity for rapid adoption.

Yes! Need this!!! You can push a lib into a global variable but clumsy.

@abhijitkane are any news about these features?

This is needed

@wkuckro @niraida @DaveData @wheelspinner @bolerio At the time of writing, the Postman Sandbox supports libraries enumerated here: https://www.getpostman.com/docs/sandbox

Please comment on the specific libraries that you wish to see in future releases of the Sandbox, so the we may plan Sandbox growth better.

momentJS

This is not a part of our current roadmap, but has been marked as a feature request and added to our internal tracker. We'll update this thread when any progress occurs on this. :)

Postman/newman was checking all the boxes for rest api automation and then I hit this issue (i.e. not allowing to import custom js) this would be such a useful feature and in my opinion complete Postman.

@wkuckro moment-js is available in Neman v3.7.0 and above, you can use it in your test scripts as follows:

var moment = require('moment');

// do stuff here...

Hi, Is it going to be possible to add this feature? I think is good to use own libraries to not repeat too much yourself.

Using custom NodeJS modules from NPM is not in near or mid term roadmap. Mostly because the provisioning and security concerns that we need to resolve first. Adding this feature even at Newman and app level will cause workflow issues for majority of people who move between Newman, monitors and the app frequently.

Presently, there are ways around this:

  1. execute repeated code in collection / folder level scripts
  2. use variables to store script and eval them (not recommended though.)

Having said that, we are constantly looking into a seamless way of doing this and we are considering ability to declare script dependencies in collections and so on. So, feel free to +1 the thread mentioned below or add more comments.

Duplicate of: https://github.com/postmanlabs/postman-app-support/issues/1180

Was this page helpful?
0 / 5 - 0 ratings