Ticket: Projection - 5000ms timeout

cursor = await movies.find({countries: { $in: countries }}, {title: 1} )
Ok for 1 country but failed for 3 due to timeout. Here’s symptom:

● Projection › Can perform a country search for three countries

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  12 |   })
  13 | 
> 14 |   test("Can perform a country search for three countries", async () => {
     |   ^
  15 |     const countriesList = ["Russia", "Japan", "Mexico"]
  16 |     const movies = await MoviesDAO.getMoviesByCountry(countriesList)
  17 |     expect(movies.length).toEqual(2788)

  at Spec (node_modules/jest-jasmine2/build/jasmine/Spec.js:85:20)
  at test (test/projection.test.js:14:3)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)
  at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:296:22)
  at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:114:21)

Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 passed, 2 total
Snapshots: 0 total
Time: 8.092s, estimated 9s
Ran all test suites matching /projection/i.
Teardown Mongo Connection
Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren’t stopped in your tests. Consider running Jest with --detectOpenHandles to troubleshoot this issue.

PS. I don’t know how to invoke Jest in command-line or test script, thus can’t follow above direction for further debugging.

I wrote a line in jest.config.js file: “setupTestFrameworkScriptFile: ‘./jest.setup.js’”, created the ‘jest.setup.js’ file. In jest.setup.js file specified the timeout for the entire tests as: jest.setTimeout(30000). The above error just vanished.

If I change the timeout value from 30000 to 100 I do get the same error as mentioned above.