Testing 流星法
我有以下简单的流星方法,我想测试。 它将一个给定的对象插入到我的集合中Testing 流星法,testing,meteor,mocha.js,Testing,Meteor,Mocha.js,我有以下简单的流星方法,我想测试。 它将一个给定的对象插入到我的集合中 Meteor.methods({ insertHelper(profile){ HelperCollection.insert(profile); return true; }, } 对于测试,我使用“dispatch:mochaphantomjs” 到目前为止,我的测试如下: describe('methods', () => { it('can delete owned ta
Meteor.methods({
insertHelper(profile){
HelperCollection.insert(profile);
return true;
},
}
对于测试,我使用“dispatch:mochaphantomjs”
到目前为止,我的测试如下:
describe('methods', () => {
it('can delete owned task', () => {
Meteor.call('insertHelper',{a: 1});
});
});
运行测试时,我收到消息“错误:找不到方法'insertHelper'[404]”
那么,如何从测试套件中访问Meteor方法呢?如评论中所述,我们必须包括定义Meteor方法的文件,以便对其进行测试:
import'/path/to/method/file.js'代码>
或使用要求:
require('/path/to/methodos/file.js')代码>
编辑
如果可以,使用导入
而不是使用要求
。是否将方法文件包括在测试文件中?谢谢!我忘了在require('../lib/lib/methods.js')中包含methods.js文件;