I send data to server and match returned data with sent data. If use expect.arrayContaining(array) to compare options and nested variants it swears on ids and fields that add db. How compare objects with arrays which contain arrays of objects ?
Data to send:
{
"name": "red dress",
"options": Array [
Object {
"name": "size",
"variants": Array [
Object {
"name": "M",
},
Object {
"name": "L",
},
Object {
"name": "S",
},
],
},
],
}
Returned data:
{
"id": "dc67efd8-dcc4-43df-a8eb-9d95ea641749",
"name": "red dress",
"options": Array [
Object {
"id": 1,
"name": "size",
"productId": "dc67efd8-dcc4-43df-a8eb-9d95ea641749",
"variants": Array [
Object {
"id": 1,
"name": "M",
"optionId": 1,
},
Object {
"id": 5,
"name": "S",
"optionId": 1,
},
Object {
"id": 6,
"name": "L",
"optionId": 1,
},
],
},
],
}
Test:
expect(body.data).toMatchObject(productData)
