-
-
Notifications
You must be signed in to change notification settings - Fork 771
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
sinon.assert.calledOnceWithExactly() does not accept a single spy call #2277
Comments
I have verified the existence locally. Don't yet know if it is a recent addition, or if it was always failing. I'll try to find some time for a |
I've managed to construct a smaller test case to produce the error const sinon = require("sinon");
let spy = sinon.spy();
spy(5, 100);
// passes
spy.calledOnceWithExactly(spy.getCall(0), 5, 100)
// throws
sinon.assert.calledOnceWithExactly(spy.getCall(0), 5, 100); This teaches me two things:
For the second, on line I guess the next step to investigate, is how But, it's past midnight here, so that'll have to wait. |
There are two things wrong with this:
My observation is that
This isn't the case anymore. In our last hackathon I've separated the implementations and the common interface is now |
Anyway, I think this is a copy-paste bug in the documentation. It makes not much sense to check that a single call was called once. If the call wasn't made at all, the result of I'd suggest to fix it in the documentation and throw a meaningful exception if |
Interesting. I was going to write a big post about how I disagreed that it doesn't make much sense, but then I discovered that The type of the first argument for I'll see if I can put together a PR to address this issue. |
I've looked into this, and I can't get my head wrapped around what in the sinon code base would convey typing hints to the good folk maintaining @types/sinon. I can update the documentation, but I'm unclear what other changes could/should be made in the sinon code base. What am I missing? Also, should I just open a related issue in the @types/sinon project to request a typing change there? |
@dpmott While we are pondering of adding TypeScript definitions generated through JSDoc annotations ourselves, like we have done in |
Describe the bug
According to the v9.0.2 documentation,
sinon.assert.calledOnceWithExactly()
can accept a single, dedicated spy call, instead of a spy. However, it throws an error instead:The exception message:
To Reproduce
Steps to reproduce the behavior:
sinon.fake()
sinon.assert.calledOnceWithExactly()
, passing a dedicated spy call usinggetCall()
, and specify the correct arguments.Expected behavior
sinon.assert.calledOnceWithExactly()
should pass it normally.Context (please complete the following information):
The text was updated successfully, but these errors were encountered: