Check if a field contains a certain value

How can I test if key gender is either 1 or 2, please?

"naturalPerson": {
        "fullName": "Teste with Luis",
        "nickName": "Pacheco",
        "gender": 2,
        "pronoun": 2,

Hi @silvio.aulik

Assuming your response looks like this:

{
    "naturalPerson": {
        "fullName": "Teste with Luis",
        "nickName": "Pacheco",
        "gender": 2,
        "pronoun": 2
    }
}

Then to check the β€˜value is 1 or 2’ you could use the following

const response = pm.response.json();

pm.test("Check value is either 1 or 2", function () {
    pm.expect(response.naturalPerson.gender).to.be.oneOf([1, 2]);
});
1 Like

Your are the best!!.. Thank you x 1000…
Be happy

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.