phantasmagoria1985
phantasmagoria1985

Reputation: 27

how to write equal test in postman for nested field equality

I like to test my api on postman, my query params according to equality

192.168.1./student/v4/students?contactStudent.validFor.endDateTime==2021-09-26T05:00:00.246Z

 "contactStudent": [
            {
                "mediumType": "email",
                "preferred": true,
               
                },
                "validFor": {
                    "endDateTime": "2021-09-26T05:00:00.246Z",
                    "startDateTime": "2017-03-15T07:49:25.246Z"
                }

my equality are working on well on postman, however how can ı write pm test for it ?

Thank you

Upvotes: 0

Views: 153

Answers (1)

PDHide
PDHide

Reputation: 19989

postman has code snipet already available:

enter image description here

so the test is

pm.test("Your test name", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.contactStudent[0[.validFor.endDateTime).to.eql("2021-09-26T05:00:00.246Z");
});

jsonData has the ful json object from taht you are accessing each property

Upvotes: 1

Related Questions