I have a test suite with a response status code validation.
One of my endpoints is throwing a 502 Gateway Error:
Postman:
Newman:
In my Newman report, my test validations are not failing:
But it’s showing under the Failed Tests tab:
I even added the following but it’s showing the same results as above:
pm.test("JSON response validation", function() {
pm.expect(jsonData).to.be.an('object');
});
How can I force the non-200 (502) assertion failure to show up? It’s misleading that it’s showing as green.
Hi @maclazaro. Welcome to the Postman Communtiy
.
The response body from the screenshots you shared is an HTML body and the test assertion you wrote only validates the response body and not the response code. To validate the response code of the request, add the test script:
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
Forgot to mention I already have the status code validation, though slightly different from yours:
pm.test("Success", function () {
pm.expect(pm.response.code).to.be.equal(200);
});
I added yours to my SCN-027 but got the same results: