# Improve test failure reporting in the Postman app - Show line of code that caused fail

**URL:** <https://community.postman.com/t/improve-test-failure-reporting-in-the-postman-app-show-line-of-code-that-caused-fail/3361>\
**Category:** Help Hub\
**Created:** [November 22, 2018, 3:55pm UTC](https://community.postman.com/t/improve-test-failure-reporting-in-the-postman-app-show-line-of-code-that-caused-fail/3361 "2018-11-22T15:55:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![postman-paul540](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/postman-paul540/32/149_2.png) [@postman-paul540](https://community.postman.com/u/postman-paul540)\
**Post date:** [November 22, 2018, 3:55pm UTC](https://community.postman.com/t/improve-test-failure-reporting-in-the-postman-app-show-line-of-code-that-caused-fail/3361/1 "2018-11-22T15:55:15Z")

</div>

TL; DR - Can we add stacktrace to errors or the line of code that failed?

After writing tests using Mocha/Chai in Node and then coming back to Postman was a huge bummer, primarily debugging was considerably difficult.

Give I’ll get the below response:

```auto
{
   "customer": {
       "customer_id": 21972,
       "customer_number": "TST999",
       "customer_type": "Standard",
       "company_name": "",
       "forename": "Testy",
       "lastname": "McTester",
       "email_address": "test@test.com",
       "telephone1": "1234",
       "telephone2": "1234",
       "fax": "1234"
   }
}

```

If I have the below code in Postman in the Tests tab:

```auto
const body = JSON.parse(responseBody);

pm.test("Expects a 200 response code", function() {
    pm.expect(responseCode.code).to.equal(200);
});

pm.test("Checks stuff", function() {
    pm.expect(body).to.have.property("customer");
    const customer = body.customer;
    pm.expect(customer).to.have.property("fax");
    // The below assertion is expected to fail
    pm.expect(customer.company_name).to.not.be.empty;
});

```

Postman will output the error

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/5/2/5220580ebc004b5218050b4267f1bab38f457c57.png)

When running the same test in mocha/chai, I’m told which line of code failed:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/2/8/28c59912be374e8825ce5c2167dd57ed20d55a90.png)

Is Postman able to tell me which line of code in my ‘Tests’ tab caused the fail?  
You could probably argue I should split up my tests up into proper ‘its’ but the issue raised is still valid…

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [December 9, 2024, 2:34pm UTC](https://community.postman.com/t/improve-test-failure-reporting-in-the-postman-app-show-line-of-code-that-caused-fail/3361/2 "2024-12-09T14:34:43Z")

</div>

Closed on December 9, 2024, 2:34pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
