Unable to call Meteor methods from mocha js


#1

Im working on a project built in Meteor + angular1 .
We are using Mocha for writing unit test-cases
.Iam unable to call a serverside method from my testjs file.I have my test file in imports folder.

my server-side method:
Meteor.methods({
testcall:function() {
console.log(‘hello there’);
return “luck”;
}

});
my test-case:

describe(‘testcall’, function () {
it(‘shuold call testcall method’, function () {
Meteor.methods.call(‘testcall’, function(error, result) {
console.log(error || result);
});
});
});

ERROR:
"Method testcall not found’’.

Any ideas?

Thanks


#2

You need to register the method in the test so it actually exists


#3

Thankyou for the reply henribeck
Can you please breif It.

Thanks


#4

Assume you have a methods.js file and a methods.test.js file

methods.test.js:

import './methods';

// Now you can call any method that you defined in methods.js via Meteor.call()