How would I go about stubbing out specific remote method calls, i.e. Meteor.call or Meteor.apply in package testing? I’m using mocha, chai, and sinon with Velocity.
If I stub out Meteor.call, it breaks Velocity since the test runner uses remote methods itself. This happens in the terminal (meteor test-packages --velocity) and the HTML reporter (meteor test-packages --driver-package respondly:test-reporter). The tests will report as passing but nothing’s actually happening.
This may be as much of a Sinon question as a Meter & Velocity one, but I can’t figure out any way to stub a method only when given certain arguments, otherwise let the function run like normal.
You could try monkey patching the method and conditionally bailing on it depending on the arguments. So something like:
Meteor.__call = Meteor.call;
Meteor.call = function(name) {
// check the params here and do something, maybe even assert here
if (name === 'aSpecificMethod') return;
return Meteor.__call.apply(this, arguments);
}