Kill any currently running MongoDB instances.
npm install kill-mongodb
yarn add kill-mongodb
pnpm add kill-mongodb
bun add kill-mongodb
Kill any currently running MongoDB instances on OSX, Linux, or Windows.
npm install --save-dev kill-mongodb;
If your tests start mongodb, you can just add a handy posttest hook to kill off any instances that might be lingering.
posttest
{ ... "scripts": { "test": "mocha", "posttest": "kill-mongodb" } ... }
Apache 2.0