Reputation: 69
How can I assert null values in Postman. I know i should assert the "non-null" values and I'm doing this as well.
Here is my code:
pm.test("Validate Approval is correct", function(){
if(IsEx === 1){
pm.expect(data.Approval).not.eql(null);
}else if (IsEx ===0){
pm.expect(data.Approval).equal(null);
//pm.expect(data.Approval).eql(null);
//pm.expect(data.Approval) === null;
//pm.expect(data.Approval).include(null);
}
});
Basically the value approval is dependent on IsEx, I shouldn't be needing to check the null values, but in this case i need to. The problem I'm getting is "AssertionError: expected null to not deeply equal null".
Upvotes: 0
Views: 2457
Reputation: 880
you can use
pm.expect(data.Approval).to.be.undefined;
or
pm.expect(data.Approval).to.be.null;
depending on your needs.
You can also take a look at the chai reference for this topic.
Upvotes: 2