Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

312
Views
Trigger a New Request if a Test fails in Postman (CollectionVariable?)

I'd like to trigger a new request automatically if a postman test fails. Currently, in each request I have about 30 tests running based on what I'm expecting in the request's response. Test Example:

pm.test("YES",() => {
    var yes = pm.response.json().eligibility_results.filter(obj => {
        return obj.benefit == "YES" 
    })
  pm.expect(yes[0].result).to.eql("eligible")
});

Now, If anything else other than the string "eligible" results for this object, the test will fail. I'd like to write a script that tells postman if one of the 30 tests come back as a failure (not expected) a new request will automatically be initiated.

I've tried:

    pm.test("Check for failures", () => {
    if (pm.expect().not.eql("")) {
        (pm.sendRequest("New Request"))
    }
    else {
        pm.sendRequest(null)
        
    }
})

Also tried:

pm.test("Check for failures", () => {
    if (pm.expect(pm.response.result()).not.eql) {
        (pm.sendRequest("New Request"))
    }
    else {
        pm.sendRequest(null)
        
    }
})

I seem to be missing something here. The tests are giving me a PASS in the Test Results but it isn't initiating a new separate request. Any options?

Maybe a Post-Request if there is such a thing...

Any help greatly appreciated.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!