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
ClockDate class overwrite prototype of instance #437
Comments
This is probably a bug because when you
We should probably fix the code to not do that or call |
Where do we do that? I could not see this happening in the example code. |
Our |
@Oustinger The quickest path to seeing a patch commit for this is probably submit a small PR with a fix and regression test. I can make a release quick, but I do not have time atm to debug, fix and verify this. |
@fatso83 I would do that. But I couldn't find a place to fix on my own. |
No one would expect you to 🙂 I certainly did not. Do you think you have the hints you need? |
Where is a place in code, where new date's prototype becomes equal to ClockDate? |
You cannot get deeper than that function, but the setup of the prototype happens before that https://github.com/sinonjs/fake-timers/blob/main/src/fake-timers-src.js#L446-L489 covers all the return bits where we create
Not totally sure how to fix the code myself TBH. ~I am guessing we are invoking NativeDate to create Date objects that are identical in behavior to the NativeDate, and if we were not to invoke This fixed the issue when I tested:
Not sure if this is a general fix, but try and see if the test suite works when doing it for all paths :) |
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. |
ClockDate class overwrite prototype of instance.
In my real project it happens when I use datepicker library (@eonasdan/tempus-dominus).
What did you expect to happen?
I expected to receive instance of DateTime with it's methods
What actually happens
Prototype of child instance is not equals to DateTime class, but equals to fake date class
How to reproduce
I'd created a repository with reproducing this problem
i. You can clone and run project
ii. Or you can create project with @sinonjs/fake-timers and run the code below by yourself
The text was updated successfully, but these errors were encountered: