question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

responseTime and responseBody result in "ReferenceError in test-script" when timed out

See original GitHub issue

(Newman 3.2.0, node 6.9.1, win 10)

Even if Tests contains any of these, the tests will throw ReferenceError in test-script when timed out.

tests[`WTF!!`] = responseBody || false;

tests[`WTF!!`] = responseBody != null;

tests[`WTF!!`] = responseBody ? true : false;

if (!responseBody) {
  // xxx
}

Same is true for responseTime

“Thanks” to this, my boss thought I didn’t write any assertions…

image

For now, I use this to work around it.
But it will be much better to have a better official html report template. : )

tests[`server does return something before timeout`] = postman.getResponseHeader('Content-Type') || false;

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
shamasiscommented, Dec 1, 2016

I have one more point here. Even if things timed out, is it okay to have RefeferenceError? Instead, should the global variables not be set to undefined (or whatever appropriate to indicate timed out)? By that, scripts will not error out and will fail tests properly.

0reactions
shamasiscommented, Aug 8, 2019

Update on the issue. Since 2017, a lot has changed.

  1. The new pm.* functions have superceeded the global variables concept. Functions are easier to test and trap errors for, unlike global variables.
  2. Work is in progress to configure scripts to be run even on network error of requests

The above two combined, this issue will be auto addressed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Test script examples - Postman Learning Center
Your tests can check various aspects of a request response, including the body, status codes, headers, cookies, response times, and more. Testing response...
Read more >
There was an error in evaluating the Pre-request Script
Try putting your script under the Tests tab, which is ran after a response is received. Share.
Read more >
JavaScript policy runtime error troubleshooting | Apigee Edge
The error type ReferenceError is thrown when an undefined variable in your JavaScript is used (referenced) or operated on. Error response body.
Read more >
ReferenceError: $http is not defined - New Relic Explorers Hub
I am try to write a simple script in new relic synthetics and am getting : ReferenceError: $http is not defined. Part of...
Read more >
Error and Warning Dictionary | Twilio
HTTP communication total time out triggered ... Conference Event: Error Response to Callback URL ... Address Validation Error - Check Suggested Address.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found