Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding multiple expect.objectContaining, overrides each other #323

Open
ghost opened this issue Nov 24, 2021 · 0 comments
Open

Adding multiple expect.objectContaining, overrides each other #323

ghost opened this issue Nov 24, 2021 · 0 comments
Labels

Comments

@ghost
Copy link

ghost commented Nov 24, 2021

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: ... }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant