ryne:dbreset

Reset your database in test.


Install
meteor add ryne:dbreset@=0.1.0

Documentation

A Meteor package for safely resetting your database between test runs.

Usage

1. Install.

meteor add ryne:dbreset

2. Add the function to your server-only Meteor methods.

if (Meteor.isServer) {
  typeof DBReset !== 'undefined' && Meteor.methods({DBReset: DBReset});
}

3. Use the method in your test fixtures.

The DBReset method takes one argument -- an array of strings representing collection names. Nested namespaces can be accessed through period-delimited strings.

Here is a mocha example.

beforeEach(function(done) {
  Meteor.call(
    'DBReset',
    ['WidgetCollection', 'GadgetNamespace.BlueCollection'],
    function() {  // optional callback
      setTimeout(function() {
        done();
      }, 50);
    }
  );
});

Reference

Collections Clearing

Remove all documents from specified collections.

DBReset(collectioNames)

collectionNames (required), an array of strings representing collection names. Nested namespaces can be accessed through period-delimited strings.