Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

316
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda