Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Testing 流星法_Testing_Meteor_Mocha.js - Fatal编程技术网

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文件;