-
Notifications
You must be signed in to change notification settings - Fork 108
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
ClockTime constructor name is different, breaking mongoose Date checks #510
Comments
Hi, great report. We are trying to do semantic releases, which means that when going from version 11 to 12, you will know there are breaking changes. So there are at least two breaking changes between version 11 and 13, of which this is the most important change in version 12. So currently it works as intended, but that does not mean we cannot do stuff to make life easier for people, if it is not a big deal. We did this in #505, for instance, to make
After checking out your link to the Mongoose code, I see that they are not comparing function references, but the names of those functions (constructors):
This is something we can do something about. Do you want to supply a fix? Usually the quickest way to get it done, if you need it. |
Fix supplied. Should fix your case. |
|
Thanks so much! That was super quick. It does indeed fix the issue partially, but in some situations it's sadly still not working. I'll dig deeper and see about creating a PR if it's fixable. |
What did you expect to happen?
We're using Sinon together with mongoose. When using mongoose's
toJSON
andtoObject
to turn mongoose documents into plain objects while faking timers I'd expect fields with Date objects to remain Date objects (or at least look like them). This is the case in fake-timers 11.2.2.What actually happens
While faking timers, when calling
toJSON
ortoObject
on a mongoose document, it turns any Date fields into a number (unix timestamp). This seems to happen because mongoose determines whether an object is a Date or not using the constructor name.How to reproduce
Hope this is the right place to report this.
The text was updated successfully, but these errors were encountered: