-
Notifications
You must be signed in to change notification settings - Fork 107
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. |
…y BREAKING) See #437 for background. All tests run fine and I have no reason to expect this to do anything but improve things, but it is changing something that has been working for a long time. * fix: save methods of children Date instance (#437) * rename see pr comment * fix skipped tests by ensuring we are checking something meaningful. * refactor: trim out code that will never be hit in the Proxy --------- Co-authored-by: Степан Карташев <kartashev@byndyusoft.com> Co-authored-by: Carl-Erik Kopseng <carlerik@gmail.com>
I fixed up the last few bits of your original PR and merged it. Thank you a bunch for making it! I'll close this and release a version 12 shortly. |
## Proposed change The original issue sinonjs/fake-timers#437 was fixed in `@sinonjs/fake-timers@>=12` We get this dependency from `@jest/fake-timers` but it is still using version 10 It seems that even in Jest 30 the dependency won't be updated to v12 ## Related issues - 🐛 Fixes #(issue) - 🚀 Feature #(issue) <!-- Please make sure to follow the contributing guidelines on https://github.com/amadeus-digital/Otter/blob/main/CONTRIBUTING.md -->
## Proposed change The original issue sinonjs/fake-timers#437 was fixed in `@sinonjs/fake-timers@>=12` We get this dependency from `@jest/fake-timers` but it is still using version 10 It seems that even in Jest 30 the dependency won't be updated to v12 ## Related issues - 🐛 Fixes #(issue) - 🚀 Feature #(issue) <!-- Please make sure to follow the contributing guidelines on https://github.com/amadeus-digital/Otter/blob/main/CONTRIBUTING.md -->
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: