-
-
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
.calledWith() on a stub broke in sinon 4.4.10 #1756
Comments
@nfriedly, this is most probably related to merging #1738. Could you shine some light on this? Runnable example const sinon = require("./lib/sinon.js");
function createResponse() {
return 42;
}
function validateResponse() {
return true;
}
function downloadResponse() {}
const stub = sinon
.stub()
.onCall(0)
.resolves(createResponse)
.onCall(1)
.resolves(validateResponse)
.onCall(2)
.resolves(downloadResponse);
stub(100);
console.log("calledWith", stub.calledWith(100)); // fails with '... is not a function' |
Yea, I think this variation will work as desired: const stub = sinon.stub();
stub.onCall(0)
.resolves(createResponse)
.onCall(1)
.resolves(validateResponse)
.onCall(2)
.resolves(downloadResponse); |
After first thinking this is real regression (I marked 4.4.10 transiently as I think this might as well be addressed by adding an explicit test in our test arsenal that asserts that the behaviour adding methods (such as What do you think, @mroderick? |
Closing this as a non-bug, as our official stance has been that using inlined stubs is not supported: #1748 (comment) I'll try to open a new feature request issue to see if we can improve the situation. |
I think that would be a great idea, as it makes it clear what the intention is, without having to resort to using |
I have done a lot A problem is that the feature description was not fully covered by the tests in that same PR. The tests explicitly just tested that Fluent APIs always gets these problem at some point, when you start returning a different object than you originally started with 🤢 As a temporary solution I have deprecated 4.4.10, but we will need to discuss the next step. |
Please continue this discussion in #1757 |
What did you expect to happen?
Tests to work as before
What actually happens
Tests break with '.calledWith is not a function' exception.
How to reproduce
calledWith
on that stubDowngrading to 4.4.9 solves the issue.
The text was updated successfully, but these errors were encountered: