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

175
Views
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 answers
Answer question

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 Report
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!