I am using Cypress to do E2E tests. I am using the Sinon.Chai chainer be.calledWithMatch
to test that an alias was called with matching arguments:
cy.get('@myAlias')
.should('be.calledWithMatch', {
param: 'value',
otherParam: 'other value'
});
The assertion works as expected, but provides the following non-explicit error message:
expected myAlias to have been called with arguments matching Object{2}
What I would like is to use a chainer allowing me to:
- Test something was called with matching arguments (just like
be.calledWithMatch
) - Provide an explicit assertion message that shows the expected values. For example:
expected myAlias to have been called with arguments matching { param: 'value', otherParam: 'other value' }
I thought of using a combination of .wrap()
, .find()
and .should('eq')
, but that would be much complex. Is there a more appropriate chainer to achieve what I expect?