mocha-mongoose
mocha-mongoose copied to clipboard
`noClear` does not work with multiple test modules
Hi!
Here's the scenario:
if I run a single test file with { noClear: true }
- it works OK
if I run a single test file with { noClear: false }
( or no option ) - it works OK
but
if I run mocha test/
where test/
is a folder containing 2 tests above - looks like mocha
will still always run the clearDB
on beforeEach
and my #1 test will always fail.
Most likely it's due to the global variables in https://github.com/elliotf/mocha-mongoose/blob/be8a52ee947c25ad59bc8dee8a85777ad88cdf8b/index.js#L5:
var beforeEachRegistered = false;
var afterHookRegistered = false;
It would be good to "scope" these vars into the instance of clearDB