Closed orelHunters closed 8 months ago
it doesnt really make sense, but are the 2 model calls maybe on different connections / mongoose instances?
if that is not the case, does anything change if you remove the following?
beforeEach(() => jest.useFakeTimers());
afterEach(() => jest.useRealTimers());
also did you already try a higher mongoose version?
it doesnt really make sense, but are the 2 model calls maybe on different connections / mongoose instances?
if that is not the case, does anything change if you remove the following?
beforeEach(() => jest.useFakeTimers());
afterEach(() => jest.useRealTimers());
also did you already try a higher mongoose version?
OMG the issue was actually because of the fake timers... Not sure why it's the only thing I didn't try :/ It works now. TYSM!
Versions
package: mongo-memory-server
What is the Problem?
I'm trying to add some tests to my node project using Jest + mongodb-memory-server (debug). I'm using globalSetup / globalTeardown for the initialization/destruction of the server and beforeAll/afterAll for connecting/disconnecting. I'm also able to see the server initializing and being connected to in the debug logs. I'm also doing a sample 'find' call within the context of 'beforeAll' after connecting and it works (returns empty).
However when the test itself reaches the part where it queries the Mongo it just hangs forever and doesn't produce any debug messages. This is very strange considering the same call just worked in the context of 'beforeAll' but doesn't work within the test while there isn't any debug output from the binary in between.
Code Example
jobs.test.ts
jobs.ts
globalSetup.ts
globalTeardown.ts
jest.config.ts
Debug Output
link to logs
Do you know why it happenes?
no