SOLVED: User-report test - test hangs openhandles

from console I get
MongoDB Enterprise mflix-shard-0:PRIMARY> db.comments.aggregate(pipeline, readConcern).pretty()
{ “_id” : “roger_ashton-griffiths@gameofthron.es”, “count” : 909 }
{ “_id” : "bradley_brooks@fakegmail.com", “count” : 880 }
{ “_id” : "megan_richards@fakegmail.com", “count” : 880 }
{ “_id” : “nathalie_emmanuel@gameofthron.es”, “count” : 874 }
{ “_id” : “paul_kaye@gameofthron.es”, “count” : 870 }
{ “_id” : “gemma_whelan@gameofthron.es”, “count” : 868 }
{ “_id” : "john_rice@fakegmail.com", “count” : 867 }
{ “_id” : "blake_sellers@fakegmail.com", “count” : 867 }
{ “_id” : “ben_hawkey@gameofthron.es”, “count” : 867 }
{ “_id” : “aidan_gillen@gameofthron.es”, “count” : 866 }
{ “_id” : “dean-charles_chapman@gameofthron.es”, “count” : 863 }
{ “_id” : "robert_jordan@fakegmail.com", “count” : 861 }
{ “_id” : "lori_blankenship@fakegmail.com", “count” : 860 }
{ “_id” : "edward_barrett@fakegmail.com", “count” : 859 }
{ “_id” : “iain_glen@gameofthron.es”, “count” : 859 }
{ “_id” : "kathryn_sosa@fakegmail.com", “count” : 859 }
{ “_id” : “jonathan_pryce@gameofthron.es”, “count” : 856 }
{ “_id” : “jason_momoa@gameofthron.es”, “count” : 856 }
{ “_id” : “anton_lesser@gameofthron.es”, “count” : 855 }
{ “_id” : “ian_beattie@gameofthron.es”, “count” : 853 }

but the test hangs as follows:

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.

Interesting I ran the status pg and i received a confirmation code that passed the test. I’m wondering, I’m using cloud 9 io and maybe the ide timeout. either way problem solved.

The likely reason the test is hanging is because you missed a step. Note the test conditions only expect 20 results, so there needs to be something in the pipeline doing that.

Please don’t actually share your pipeline here, but the other hint is that it should only have three stages. Any more ( or less ) and you are likely doing something less than optimal, which would increase the execution time.

Also make sure you are actually calling toArray() before returning from the function, otherwise it’s just a Cursor and not a Promise as is expected. Given that’s there’s only one function with one async call, then not closing off that operation would result in such an error as you have seen

Same here. User Report field is OK in status page but the test fails because of a timeout in jest.

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