Test .only.includes.all.keys([keys])

My question:
Hi! if i have a json like this: {“a”:1,“b”:2}. i want to prove that any other property does not exist. like, “c” not exist but at the same time, “name” do not exist.

I don’t want to do pm.expect(jsonData).not.to.include([“c”,“d”,“name”,“number”,etc])

Hey @spacecraft-astronau2 :wave: , Welcome to the community :confetti_ball:

I think what you are looking for, is to validate the property. You can use ‘.hasOwnProperty’ method to check for it:

//example
pm.test("Properties validated",()=>{
pm.expect(response.hasOwnProperty('a')).to.be.true;
pm.expect(response.hasOwnProperty('b')).to.be.true;
pm.expect(response.hasOwnProperty('c')).to.be.false;
// .....etc
})

If your response includes an array of data, have a look at this scenario:

Good luck :+1:
Hope it helps.