-
-
Notifications
You must be signed in to change notification settings - Fork 770
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
Spy's thisValue not pointing to instance when spying constructor #1683
Comments
This is a good candidate for using It shouldn't be that difficult to turn the example @PVince81 provided into a small test script that can be used for If you don't know how to use http://www.marclittlemore.com/how-to-find-bugs-using-git-bisect-with-this-easy-guide/ |
Oh, I love bisecting! I'll take care of this.. |
When an object is not created with |
considering that our code only has a single usage of this I'd be rather tempted to go the quick route and change our single test that triggered this as I don't have time to wrap my head around sinon's internals and don't feel qualified to make potentially breaking changes since not that many people seems to have complained about this issue, maybe people usually don't test this way and a fix isn't worth it (just an observation, up to the maintainers to decide) |
Even if it is not commonly used, or at least not commonly reported, I'd like to have this regression fixed. |
Encountered the same issue, is there any plans on fixing this? |
@ivan-zakharchuk If no-one is volunteering, there are no plans, no. If you want it fixed, there's a natural next step that could be taken ;-) This is the offending commit: #1683 (comment) |
Just to say, I have spent a long time trying to write a fix for this, but have been unsuccessful. It's a nightmare of Essentially, fixing this means trying to have it both ways - calling I hope the above makes sense, please feel free to correct/request clarification. See here for a refresher on what the Anyhow, one thing I did notice was that 911c498 (the commit that introduced the regression) does not include a test covering the issue it addresses - the requirement to use |
Six years since inception, I thought I would have a quick go... but man, is this a minefield of mutable state popping out its warts everywhere 😅 Changing a single line will easily trip up between 80 and 200 tests. If no one else is able to touch this either I am inclined to just remove the prop altogether. |
This snippet works fine with Sinon 2.0.0 but fails with Sinon 4.2.2:
It looks like the
thisValues[0]
object is a proxy and does not refer to the actual instance ofsome
.This is the error with Sinon 4.2.2:
The text was updated successfully, but these errors were encountered: