typegoose / mongodb-memory-server

Manage & spin up mongodb server binaries with zero(or slight) configuration for tests.
https://typegoose.github.io/mongodb-memory-server/
MIT License
2.56k stars 185 forks source link

[SOLUTION] Jest and Fake Timers #824

Closed DominicVonkPON closed 10 months ago

DominicVonkPON commented 10 months ago

Discussed in https://github.com/nodkz/mongodb-memory-server/discussions/823

Originally posted by **DominicVonkPON** October 30, 2023 If you encounter a problem with Jest where the tests are not running due to the fake timers, it could be because MongoDB memory server relies on nextTick. To resolve this issue, you should avoid faking the nextTick function. By allowing the natural behavior of nextTick, you should be able to run the tests successfully with Jest. ```javascript jest.useFakeTimers({ doNotFake: ['nextTick'], // do not fake nextTick behavior for mongo in memory }); ```
hasezoey commented 10 months ago

why exactly was this opened as a issue too?