Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

178
Vistas
How to add parameter name to error message in Postman test

I'm writing some tests in Postman. When writing the error message, I must input manually the name of the variable that is being tested. Is there a way to avoid having to put it by hand? In some tests, there are 200 variables. If something like "pm.response.parameter" existed it would be of great help as you could write a generic error message and just have to paste it in all messages.

At the moment i am using something like:

pm.expect(value.proctrEs).to.eql(null,"error en proctrEs : "+pm.response.code);

But I was wondering if there is something like:

pm.expect(value.proctrEs).to.eql(null,"error en "+ pm.response.parameter + " " + pm.response.code);

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This function will be like this:

function checkProperty(path, value) {
    let property = path.split(".").at(-1);
    pm.expect(eval(path)).to.eql(value,`error en ${property}: ${pm.response.code}`);
}

Example:

const res = pm.response.json();

pm.test("check response", () => {
    checkProperty("res.headers.host", "postman-echo.com1");
    checkProperty("res.url", "http://postman-echo.com/get1");
})

Tested with http://postman-echo.com/get

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda