Hello, thank you for your answer but those flags unfortunately don't turn off those warnings but I just wanted to know if those warnings mean anything meaningful or should I just brush it off? Cheers!
Edit. I'm fairly new to Node/Nest stuff, could you please also tell me how can I add helper method to this utility to clear all collections? Cheers!
Could you maybe provide a full example of that? I tried to get this working in my own repo and in yours, using the Squid model, but got an error in both cases: Nest could not find Squid element (this provider does not exist in the current context). Much appreciated!
You can check my Colonie repo. The pvp-shield module have the in memory db, collection deletion between it and the way to get the model from the testing module. github.com/bassochette/colonies/tr...
Thanks a lot, I managed to do it! For others who might struggle: I wasn't aware of the convention for the model name to use in module.get(). It's the name property that gets passed into MongooseModule.forFeature() + the suffix 'Model' (SquidModel in this example). Apologies if this obvious, but this string is never explicitly defined as a constant or class name etc.
Oh, that's really not obvious...
I found this trick by mimicking the underlying metod of InjectModel from the nest/mongoose repo. github.com/nestjs/mongoose/blob/28...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Pawel,
Sometimes I have this message. I tweaked a bit by test command with a few options.
--detectOpenHandles
should help you find the non-closing process. It might also remove the message--force-exit
will make sure to kill the process and allow your test to run smoothly on CI environments. It is a bit barbaric but it gets the job done.I've done a few tests before replying. The first screenshot does not use the
--detectOpenHandles
options and the seconds do."test:watch": "jest --watch",
"test:watch": "jest --watch --detectOpenHandles",
Hello, thank you for your answer but those flags unfortunately don't turn off those warnings but I just wanted to know if those warnings mean anything meaningful or should I just brush it off? Cheers!
Edit. I'm fairly new to Node/Nest stuff, could you please also tell me how can I add helper method to this utility to clear all collections? Cheers!
You don't need to clear collection between tests since it's a new in-memory mongo.
during the test I do something like that:
like the service in the test, the module needs to be accessible.
Could you maybe provide a full example of that? I tried to get this working in my own repo and in yours, using the
Squid
model, but got an error in both cases:Nest could not find Squid element (this provider does not exist in the current context)
. Much appreciated!You can check my Colonie repo. The pvp-shield module have the in memory db, collection deletion between
it
and the way to get the model from the testing module.github.com/bassochette/colonies/tr...
Thanks a lot, I managed to do it! For others who might struggle: I wasn't aware of the convention for the model name to use in
module.get()
. It's the name property that gets passed intoMongooseModule.forFeature()
+ the suffix 'Model' (SquidModel
in this example). Apologies if this obvious, but this string is never explicitly defined as a constant or class name etc.Oh, that's really not obvious...
I found this trick by mimicking the underlying metod of
InjectModel
from the nest/mongoose repo.github.com/nestjs/mongoose/blob/28...