@bpricilla @singhsivcan Hi! I’m trying to apply your suggestions that you gave, but I can’t. Could you guide me on the right path?
my response body:
{
"data": [
{
"id": 1117,
"acceptance": {
"externalId": "33232"
},
"statusIdFrom": {
"id": 1,
"name": "Create"
},
"statusIdTo": {
"id": 1,
"name": "Create"
},
"createdAt": "2021-11-26T06:20:08.717Z",
"updatedBy": {
"id": 15,
"name": "production",
"fullname": "production",
"departmentId": 1
}
},
{
"id": 1118,
"acceptance": {
"externalId": "33234"
},
"statusIdFrom": {
"id": 1,
"name": "Create"
},
"statusIdTo": {
"id": 1,
"name": "Create"
},
"createdAt": "2021-11-26T07:57:34.108Z",
"updatedBy": {
"id": 15,
"name": "warehouse",
"fullname": "warehouse",
"departmentId": 1
}
},
{
"id": 1119,
"acceptance": {
"externalId": "33236"
},
"statusIdFrom": {
"id": 1,
"name": "Create"
},
"statusIdTo": {
"id": 11,
"name": "Delete"
},
"createdAt": "2021-11-26T07:57:35.238Z",
"updatedBy": {
"id": 15,
"name": "fabric",
"fullname": "fabric",
"departmentId": 1
}
}
],
"quantity": 5449
}
I’m trying to check the sorting by “updatedBy.name”
I tried to do this:
var resp = JSON.parse(responseBody);
console.log(resp.data[0].updatedBy)
var _ = require('lodash')
pm.test('Employee names are in sorted order', () => {
var expectedSortedOrder = _.orderBy(resp.data[0].updatedBy, ['name'],['asc']);
pm.expect(resp.data[0].updatedBy).to.eql(expectedSortedOrder);
});
I get an answer:
FAIL
Employee names are in sorted order | AssertionError: expected { id: 15, name: ‘production’, …(2) } to deeply equal [ 15, ‘production’, …(2) ]