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
Documentation for Getter/Setter spying and stubbing #1606
Comments
Is this what you were looking for? I also see this written, but it seems outdated (used to be true):
Normal stubs can be used for that now. |
For stubs that looks like it. I don't know of there is anything in the spy docs for them. |
Hmm ... I don't actually think spying has been implemented for getters/setters. I don't really know why either. The implementation would basically just be something like this: fn=Object.getOwnPropertyDescriptor(obj, prop).get
spy=sinon.spy(fn);
Object.defineProperty(obj, prop, { get: spy }) Care to take a stab at it? |
It would be great to have it documented, thank you! |
For sure, I'll knock it out. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Is there any way to spy it without class ( Directly by object )? |
@mouse9 It is unclear what you are asking, and how that relates to stubbing/spying on getters. I don't understand what you mean by classes either. Classes has no real meaning in javascript and in most regards what you think of as classes are nothing more than objects. In any case, we are trying to keep the GitHub issues list tidy and focused on bugs and feature discussions. This ticket looks like a usage question; please post it to StackOverflow and tag it with If you feel that your topic is an issue with Sinon, please open a new ticket and follow the guidelines for reporting an issue. |
For @loganhuskins 's code: Found that, in assertion, do need to assert on spy.get like: Previously was asserted on spy only, and didn't work. |
Hey all,
Is there currently documentation anywhere on how to use the getter and setter spying features outlined in #1205? If not, I could read through the code and tests and add that in if it's needed. I searched pretty hard and did not see it anywhere do I figured I'd ask. Thanks.
The text was updated successfully, but these errors were encountered: