postmanlabs / postman-app-support

Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.
https://www.postman.com
5.84k stars 839 forks source link

Detect requestor/runner/newman in PR/Test scripts #2578

Open 0xHiteshPatel opened 7 years ago

0xHiteshPatel commented 7 years ago
  1. Postman Version: 4.9.2
  2. App (Chrome app or Mac app): Mac app
  3. OS details: Mac OS 10.11.6
  4. Is the Interceptor on and enabled in the app: No
  5. Did you encounter this recently, or has this bug always been there: N/A
  6. Expected behaviour: N/A
  7. Console logs (http://blog.getpostman.com/2014/01/27/enabling-chrome-developer-tools-inside-postman/ for the Chrome App, View->Toggle Dev Tools for the Mac app): N/a
  8. Screenshots (if applicable)

Is there any way to detect whether a request is running from requestor vs runner vs newman in a PR or Test script? I'm trying to modify tests based on how a request is run to allow unattended test runs but can't find a way to detect this.

If this is not available could it be added as a variable/function available in the PR/Test sandbox (e.g. postman.getRunMode())?

vegetableman commented 7 years ago

@0xHiteshPatel Thanks for reporting this issue 👍 . Could you elaborate more on the use-case ?. What do you mean by unattended test runs?

0xHiteshPatel commented 7 years ago

I'm working on a framework that allows quick prototyping of polled workflows. We would like to enable different variations of pass/fail reporting via tests[] based on how the collection is run. Currently the user has to toggle this via a global/env variable, however, it would be better if we could auto-detect how the user was running the collection.

shamasis commented 7 years ago

@a85 we need to decide whether we should do this since we are trying hard to unify all runtime hosts and difference during run can be confusing.

0xHiteshPatel commented 7 years ago

For reference the framework is here:

https://github.com/0xHiteshPatel/f5-postman-workflows

zdhalhc commented 4 years ago

My use case is, I’d like to prevent (accidental) invoking of requests directly from postman. These are requests that are put in a folder made for Collection Runs only.

I realize I could introduce additional environments for this but it would require additional environments and/or user effortand I'd like a solution that works in all environments.

VicKetchup commented 4 years ago

We have taken a lot of steps to improve Postman performance in all scenarious, however in some cases it's a choice between having smoother running app and monitors that take longer to run and therefore may timeout. Having a way to identify where the execution is happening will allow us to use different approaches and ensure best performance in all cases.

seangarner commented 3 years ago

I have a usecase where I'd like to add a delay to a single request in a series of requests, but only when it's being run within the runner or newman. A flag somewhere would work.

A workaround would be to create an environment variable and duplicate the environment you're using and setting a flag in the duplicated env. That's untenable for me due to the overhead of keeping those environments in sync.