-
-
Notifications
You must be signed in to change notification settings - Fork 769
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
Stub of an object property with getter/setter doesn't work #1018
Comments
|
Hey, can someone confirm whether this works with the new version? I'm running @elado's code snippet with |
@mantoni Was your commit dropped somehow? You point to f7cba98 as the solution to the problem, but I can't find that commit in master (could be failing at git-fu), and the problem is not fixed when I install sinon in either of these ways:
|
@rclark I can find the commit in master when I go through the commit history, and the important change is still in current HEAD: sinon/lib/sinon/util/core/walk.js Line 23 in 1e0b237
So I'm wondering if this was either re-introduced by some other change or if there is another issue. |
Thanks for tracking that down @mantoni -- I would have to agree that either there was a regression or the commit you've indicated solved something other than this specific issue. It looks to me (having never worked on sinon before) like the issue is entirely in the In master, the problems starts here sinon/lib/sinon/util/core/wrap-method.js Line 68 in 1e0b237
methodDesc is defined as an object with a value property.
Then, here: sinon/lib/sinon/util/core/wrap-method.js Line 86 in 1e0b237
.value property, which returns undefined .
Now the sinon/lib/sinon/util/core/wrap-method.js Line 72 in 1e0b237
A very simple failing test case indicating that the issue is not fixed: var sinon = require('sinon');
var val;
var obj = {
get foo() { return val; },
set foo(v) { val = v; }
};
var stub = sinon.stub(obj, 'foo'); |
Thanks for tracking it down. Your research tells me that this is different issue than the one reported here, however with the same outcome. Reopening the issue. Can you send a pull request adding the failing test? Or even have a stab at fixing it? |
I've created a repository of demos with the following branches:
With
You can try it out yourself in this branch: https://github.com/mroderick/sinon-demo-getter-setter/tree/fail-in-1.17 |
If there's a method that was defined with
defineProperty
with avalue
it works, but not withget
/set
.Error is "Attempted to wrap undefined property fnGetterSetter as function".
Runnable code: https://tonicdev.com/56e1cbdb104098110026e06c/56fd90d539b35a13000ede79
The text was updated successfully, but these errors were encountered: