Can u please reply for the above query…Probably this would be last query on this post…
Sorry was busy at work , no you cannot use && because expect throws an error exception if test fails , so it won’t evaluate the next expect condition
Ok no issues…Then what else can I use to validate the above test? An IF statement or Is there any other way?
What is that you want to test what is res ?
Hi…
This is my request. I need to validate that the response retrieves records that have both filter Values in the below filterList. If condition doesn’t satisfy, response will be empty
{
“pageNumber”: 1,
“pageSize”: 10,
“sortParams”: [
{
"sortColumn": "BranchName",
"sortOrder": "Asc"
}
],
“filterParams”: {
"filterColumn": null,
"filterValue": null,
"operator": null,
"logicOperator": "and",
"isCaseSensitive": true,
"filterList": [{
"filterColumn": "BranchName",
"filterValue": "test",
"operator": "contains",
"logicOperator": "and",
"isCaseSensitive": true
},
{
"filterColumn": "BranchCode",
"filterValue": "MAA",
"operator": "eq",
"logicOperator": "and",
"isCaseSensitive": true
}
]
}
}
This is my response
{
"pageNumber": 1,
"pageSize": 10,
"totalPages": 1,
"totalRecordsCount": 1,
"succeeded": true,
"message": null,
"errors": null,
"data": [
{
"branchId": 449,
"branchCode": "MAA",
"branchName": "TEST Chennai",
"branchCodeWithName": "MAA - TEST Chennai",
"companyId": 19,
"companyCode": "GIN",
"companyCompanyName": null,
"companyCompanyCodeWithName": null
}
]
}
I have written the code in previous post for the above case
Hi…
Can u please reply.please don’t mind
pm.expect(res).to.eql(value1) && pm.expect(res1).to.include(value2)
I am sorry didn’t see the message busy day . What is res and res1 in this . Please format your comment properly I am not able to understand
This is what I have written
for(i=0;i<bodyData.data.length;i++)
{
res=bodyData.data[i].branchCode;
res1=bodyData.data[i].branchName;
pm.expect(res).to.eql(value1) && pm.expect(res1).to.include(value2)
} });
Here res and res1 are the response data. I am validating the response to check if particlular filter values are present by using && here. I have shared my request and response bodies also in my previous post. If u see my request body the logic operator to check this case is “and”. But as you previously said, I can’t use pm.expect with && , can u suggest the right way to do this.Do I need to make changes to the script I have written?
May be separate it as two different tests