But when I run it, if the scanRequest object includes the “Error” element, instead of a failed test in the Test Results pane, I get a red sign with “There was an error in evaluating the test script: Error: expected true to be false”, and in console I get “AssertionError: expected true to be false”
Hmm… ok… I think I “kinda” solved it, but I’m not sure if this would be the right way
What I did was running the pm.sendrequest PRIOR to writing the tests. In the sendRequest callback I saved the response to a variable, and then in the test I asserted against that variable that holds the response, but had to put that test inside a setTimeout function cuz it was completing prior to the request returning the response…
And now test fails correctly, no AssertionError exception
Does this make sense or is there a more elegant way to achieve it?
EDIT: this executes correctly when running from Postman… but when executing the test using newman, scanResponse seems to be empty when I do the expect