Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Meteor package for setting a database to a consistent state in test.

Notifications You must be signed in to change notification settings

ryneeverett/meteor-fixtures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A Meteor package for setting the database to a consistent state in test.

Installation

1. Add this package to your application.

meteor add ryne:fixtures

2. Install mongo-tools on your system. This is probably bundled with the mongodb package in most distributions.

3. Add the functions to your server-only Meteor methods.

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

Optional: Git ignore fixtures

You might not want to track database dumps for the sake of VCS performance.

echo 'tests/fixtures/' >> .gitignore

Example Usage

Saving Fixtures

Once you have your database in the desired state:

meteor shell
> Fixtures.saveFixtures();

Applying Fixtures

beforeEach(function(done) {
  Meteor.call('loadFixtures', function() {
    // Wait for aynchronous IO to complete before running test cases.
    setTimeout(function() {
      done();
    }, 50);
  });
});

Reference

Fixtures.saveFixtures({
  *db*: (default: `<MONGO_URL database>`), a string name of the database to save,
  *name*: (default: `'default'`), a string name of the fixtures
});
Fixtures.loadFixtures({
  *db*: (default: `<MONGO_URL database>`), a string name of the database to load,
  *name*: (default: `'default'`), a string name of the fixtures
});

About

Meteor package for setting a database to a consistent state in test.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published