based on Stop request from sending if pre-request test fails :
Is there any way to prevent the request from sending using newman due to a failed test in the pre-request script?
If you want to completely stop the execution when a test fails, you can use the --bail
flag while running the collection.
In case you want to jump to a new request right from the pre-request script when a test fails, then thereβs no way you can achieve this right now.
You might like to raise a feature request around this on our public tracker.
There are two moments:
- Skip test if pre-request script fails to keep console log clear and to avoid request and post-script execution since they are changing environment and destination system state. Since there are the same pre-request script check at folder there is 2nd moment -
- Jump to next request folder.
Thanx for the --bail but this is not the case.
yeah, Postman is a bit limited with respect to options for aborting a call in the prerequest.
I have seen people use a {{host}} global variable in the URL, and to set that to a different (bogus) value in the pre-request when they do not want to perform the call. Postman still makes the call, but at least not to the correct endpoint. If you want to avoid the post script doing anything it might do for a successful call, just check the response code is 200 before making the changes. I know this still pollutes the console log
using of {{host}} looks good till you have to set up it again before next 100 requests