I have something similar to this:
describe('list', () => {
it('returns the contents of the database', async () => {
await request
.get('/')
.expect(200)
.expect(expectedItems)
})
})
I don't care about the order (in this test) - however the test will fail if the objects in the array are not in the same order as they are in expectedItems. Is there any way to achieve this out the box or should I implement a custom expect function?
TIA
hello @Billy- The expect function is using the function assert.deepEqual to test the response body and the expectedItems array. deepEqual only returns true if the arrays are the same, and in the same order. If you don't care about order then you will need to implement a custom expect function.
Most helpful comment
hello @Billy- The
expectfunction is using the functionassert.deepEqualto test the response body and theexpectedItemsarray.deepEqualonly returnstrueif the arrays are the same, and in the same order. If you don't care about order then you will need to implement a custom expect function.