-
Notifications
You must be signed in to change notification settings - Fork 3
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
fix(sinon-chai): Added once commands for sinon methods #46
Conversation
@@ -181,7 +181,9 @@ | |||
sinonMethod("calledAfter", "been called after %1"); | |||
sinonMethod("calledOn", "been called with %1 as this", "", ", but it was called with %t instead"); | |||
sinonMethod("calledWith", "been called with arguments %*"); | |||
sinonMethod("calledOnceWith", "been called exactly once with arguments %*"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering - shouldnt this report an error based on a failed criteria? The user wont easily know now if the function has been called more than once or if it has been called with wrong arguments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I manually tested them. Users can know if a function is called more than once or with wrong arguments.
- Called more than once:
Code:
it('t', () => {
const foo = cy.spy().as('foo')
setTimeout(() => {
foo({ bar: 'test' })
foo({ bar: 'test' })
}, 500)
cy.get('@foo').should(
'be.calledOnceWith',
Cypress.sinon.match({
bar: 'test',
}),
)
})
- Wrong arguments:
Code:
it('t', () => {
const foo = cy.spy().as('foo')
setTimeout(() => {
foo({ bar: 'testing' })
}, 500)
cy.get('@foo').should(
'be.calledOnceWith',
Cypress.sinon.match({
bar: 'test',
}),
)
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, this addresses my concerns - although I believe that the first part of the error message could be more clear about what has failed. One has to deduce it from the "following calls were made" part. Having the Cypress.sinon.match
object stringified in a way it is stringified doesn't help much either.
🎉 This PR is included in version 2.9.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Related to cypress-io/cypress#9644