-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
findOne does not resolve if test code uses sinonFakeTimers #9417
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I can confirm this. Downgrading to 5.10.4 fixes the issue for me. |
We'll take a look, we strongly advise against using |
Thank you. I agree that jest mock timers is very bad. It causes a lot of troubles. But in my opinion, The issue here is that everything work in 5.10.4 and earlier versions but stop working in 5.10.5. If this is intentional, then at least we should have bumped version to 5.11 and with the documentation mentioning the breaking change. |
We strongly recommend that, instead of relying on As a temporary workaround, you can use the That being said, I mentioned this to the MongoDB driver team, mongodb/node-mongodb-native#2537 uses |
how can we tell jest to only mock setTimeout ? |
@sibelius it doesn't look like you can, Jest uses sinon under the hood anyway, so instead of using |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
I have a few tests which uses fakeTimers and advances time programatically. After updating mongoose, find/(other mongoose functions that are returned from
.model
) doesn't resolve when fake timers are set. This used to work in older versions.What is the expected behavior?
find function should not depend on timers.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
NodeJS: 12.16.1
Mongoose: 5.10.5
mongodb: 3.6.3
The text was updated successfully, but these errors were encountered: