diff --git a/src/MongoMemoryServer.js b/src/MongoMemoryServer.js index 25b6a519d..726dfafa9 100644 --- a/src/MongoMemoryServer.js +++ b/src/MongoMemoryServer.js @@ -145,15 +145,10 @@ export default class MongoMemoryServer { } async stop(): Promise { - const { childProcess, port, tmpDir } = (await this.getInstanceData(): MongoInstanceDataT); + const { instance, port, tmpDir } = (await this.getInstanceData(): MongoInstanceDataT); - if (childProcess && childProcess.kill) { - this.debug(`Shutdown MongoDB server on port ${port} with pid ${childProcess.pid}`); - await new Promise(resolve => { - childProcess.once(`exit`, resolve); - childProcess.kill(); - }); - } + this.debug(`Shutdown MongoDB server on port ${port} with pid ${instance.getPid() || ''}`); + await instance.kill(); if (tmpDir) { this.debug(`Removing tmpDir ${tmpDir.name}`);