Fixes Mongoose issue #1251 with mocha in watch mode
Works best with mocha --require=env-test
.
When you use Mongoose and run your tests with mocha --watch
, on each reload you may encounter a fatal OverwriteModelError
error.
- Install with
npm install --save-dev mocha-mongoose-fix-overwitemodelerror
- Edit
test/mocha.opts
and add the line--require=mocha-mongoose-fix-overwitemodelerror
This will ensure mocha models are properly (or brutally) reset before relaunching tests.