0

How can I fail a test in a pre-request script in Postman due to some condition and not hitting the API?

If some condition is not satisfying, I need to fail the test case, and for that API, I don't want to run that API and proceed to the next API.

For example:

I want to write a condition in pre-request,

If that pre-request is satisfied, only then should we hit the API and validate.

Otherwise, it should fail the test without hitting the API and continue to the next test.

Grant Miller
  • 27,532
  • 16
  • 147
  • 165
Pcode
  • 1
  • 1

1 Answers1

-2

There is a possibility that you can stop the workflow execution if all the Pre-Conditions are not met in Postman.

There is a postman function which you can use in the pre-conditions tab.

if(all pre conditions are not met){
   postman.setNextRequest(null);
}

postman.setNextRequest(null) would stop the workflow execution

You would get more information here