mocha-mongoose
Test helpers for using mongoose with mocha.
See the example spec (copied below) for more details.
Installation
-
install via npm
$ npm install mocha-mongoose
-
require mocha-mongoose in your spec helper (easier) or in each spec file
require('mocha-mongoose')('mongodb://your-mongodb-url-here');
-
mocha-mongoose will automatically clear all of your collections before each spec run
-
optionally provide a
skip
option to tell mocha-mongoose not to clear specific collections. require('mocha-mongoose')(dbURI, { skip: ['collectionname1', 'collectionname2'] });
Example usage of automatically clearing the DB between specs:
This is a copy of example/test.js
var dbURI = 'mongodb://localhost/demo-app-clearing-db' should = mongoose = Dummy = mongoose clearDB = dbURI; ;
Example usage of manually clearing the DB:
This is a copy of example/manual.js
var dbURI = 'mongodb://localhost/demo-app-clearing-db' expect = expect mongoose = Dummy = mongoose clearDB = dbURI noClear: true; ;