I have tried with \"!== null\", but it is returning PASS even when the field is returning 0 or \"\".
try this one:
pm.test("your-value is not null", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.your_value).not.eql(null);
});
You can access response json like :
var json = JSON.parse(responseBody);
var yourVAr = json.yourVar
if(yourVar == null){
//your var is null here
}
I have done similar, this is one part of the code and its works well Check this code
var jsonData = JSON.parse(responseBody);
for(i=0; i<jsonData.data.length; i++){
tests["due date is between given date range"] = jsonData.data[i].duedate < environment.Cenddate && jsonData.data[i].duedate > environment.Cstartdate;
tests["response body has department name"] = jsonData.data[i].department.name !== null;
}
This works as of Mar-2019:
pm.test("To Check if Value is Null", function() {
var jsonData = pm.response.json();
pm.expect(jsonData.<yourfield>).not.eq(undefined);
)};