Promises in Newman and Postman

I saw in the release notes for Newman that promises are natively supported. What does this look like now when we write our tests? I’ve been having to use callbacks throughout my code in order to work around this missing functionality and would very much like to move to this, but am unsure what this might look like.

Hey @Lampei :wave:

Welcome to the Postman Community! :postman:

I believe that update to Newman was to bring in a change made to the sandbox environment, that anything added here would run with Newman.

This is the PR that might give some more insights here.

Hi @danny-dainton
Thanks for the quick response!
So it sounds like this update forces any promises used to respect any async tasks that are performed within the sandbox. I know in the past I had tried using promises and I’ve run into an issue where something was waiting for an api call to return, but the test would “pass” without waiting for the results to return. I may have to try running some tests (thanks again for linking to the PR) to see it working now.
Would be nice to remove the need for the callbacks I’ve added, to do it via promises instead.

There are a few different topics created around the same topic - This is the one that I recall had a lot of activity before that change was made.

I might need to point you in the direction of @kevin.swiber for more granular information here, they know far more than I will ever know.

1 Like