I am using Postman in order to test, But I am stuck on using if/else in the scripts.
My goal is to test if a property is visible in the response body. if the property is not there, I want postman to expect it be empty. and move on to the next test. The properties are nested in an array.
This is what I came up with so far:
//Test of correct sub properties rijbewijs zijn meegestuurd
pm.test("Test if correct sub properties rijbewijs are sent", () => {
if (pm.expect(matchesVacatures.rijbewijs).to.be.empty);
else { pm.expect(matchesRijbewijs).to.have.property('codeSoortRijbewijs');}
});
However, the test always “fails” if the array is not empty. How do I go about this, it might be something small that have I placed incorrectly in the test, but I cant quite figure it out.