Ben Ezard
02/02/2022, 11:59 PMenableShutdownHooks(app: INestApplication) {
this.$on('beforeExit', async () => {
await app.close();
});
}
This code is important to us (since if Prisma terminates the process before Nest can gracefully shutdown, we end up with a whole bunch of leftover resources that need to be manually cleaned up), and as such I'm looking to write a test for it...but I'm unsure how to go about that - does anyone have any suggestions please?
Previously I'd have mocked the implementation of $on()
, but 3.9.0
made that readonly so that's not possible anymore (Jest only allows readonly properties to be mocked if they're not a function)