Velocity Helpers

The velocity:helpers package provide common test helpers to make common testing tasks straight forward.

Install

meteor add velocity:helpers

Testing helpers

In addition to this documentation, also look at the specs for them.
This will give you example usages. All testing helpers are methods on the VelocityHelpers global.

  • getElement(selector: string, context: element)
    Like $(selector, context) but it throws an error when the element has not been found.

  • getMethod(methodName: string)
    Returns the requested Meteor method function.

  • getMethods()
    Returns a hash of all Meteor methods.

  • spyOnMethod(methodName: string) (Jasmine only)
    Gives you a spy for a Meteor method.

  • stubMethod(methodName: string, error: Object, result: Object) (Jasmine only)
    Replaces the real Meteor method call with a stub that immediately calls the callback with the error and result objects you pass to this method.

  • waitFor(check: function, successCallback: function) (Jasmine only)
    Waits until the check function returns true and then calls the success callback.

https://github.com/meteor-velocity/velocity-helpers

Expose helpers globally

By default all testing helpers are on the VelocityHelpers object.
To have less to write in your tests, you can export the testing helpers to the global namespace by putting this code into one of your spec files:

beforeAll(function () {
  VelocityHelpers.exportGlobals();
});