axios-mock-adapter
axios-mock-adapter copied to clipboard
Adding multiple expect.objectContaining, overrides each other
When adding multiple different handlers, last one overrides previous ones:
// this one is overridden
httClientMock.onPost('/table', expect.objectContaining({ sortModel: [] }))
.reply(200, mockTableData);
// this one is the only one registered at the end
httClientMock.onPost('/table', expect.objectContaining({ sortModel: [{ sort: 'asc', colId: '1' }] }))
.reply(200, mockTableData2);
Actual:
In this example if request is done with sortModel: []. Axios will respond with not found error.
Expected:
Request with sortModel: [] responds with mockTableData
By debugging found out that in lib sources findInHandlers -> utils.isEqual(item[1], handler[1]) returns true for different jest marchers.
By the way works as expected if I just use { asymmetricMatch: ... }