Multi-Level Testing with Descriptive Responses

Is it just me or do others find the test system a little cumbersome for descriptive error messages? I have resorted to using the following logic to get the most out of postman testing and look forward to input from the postman crowd on alternative ways to achieve the same outcomes. In this example code pm.test always return true but you get the idea. I need to wrap the pm.test and console.info into a function pass and fail which would make the code much nicer to read.

This is in part driven by the fact that variables scope when you execute a single request does not lend itself to defining libraries of functions at the collection or folder level. A single request, not using run collection, does not have access to those variables/functions. It’s my biggest gripe with postman. That variable scope changes depending on how a request i executed…

if (pm.response.status == "Found") {
    if (pm.response.headers.has("Location")) {
        if (pm.response.headers.get("Location").includes("/oidc/cb")) {
            // This could be put into a pass(string) function
            pm.test(pm.info.requestName + " - Auth Successful", true);
            console.info(pm.info.requestName + " - Auth Successful");
        } else {
            // This could be put into a fail(string) function
            pm.test(pm.info.requestName + " - Invalid Redirect", false);
            console.info(pm.info.requestName + " - Invalid Redirect");
            postman.setNextRequest(null);
        }
    } else {
        pm.test(pm.info.requestName + "- No Location Header Found", false);
        console.info(pm.info.requestName + " - No Location Header Found");
        postman.setNextRequest(null);
    }
} else {
    pm.test(pm.info.requestName + " - Did not get Redirect", false);
    console.info(pm.info.requestName + " - Did not get Redirect");
    postman.setNextRequest(null);
}