Unit testing 依赖Meteor设置的测试包

Unit testing 依赖Meteor设置的测试包,unit-testing,testing,meteor,Unit Testing,Testing,Meteor,我正在尝试测试我的包,该包需要来自Meteor.settings的值。但是当我开始测试时,我得到了以下错误: Exception while invoking method 'sendData' TypeError: Cannot read property 'appKey' of undefined 我的测试: it('sends event data in proper form', function () { Meteor.settings = { myApp: {

我正在尝试测试我的包,该包需要来自
Meteor.settings
的值。但是当我开始测试时,我得到了以下错误:

Exception while invoking method 'sendData' TypeError: Cannot read property 'appKey' of undefined
我的测试:

 it('sends event data in proper form', function () {
    Meteor.settings = {
      myApp: {
        appKey: 'thisisafakeappkey',
      },
    };

    const post = sinon.stub(HTTP, 'post');

    trackEvent(event, data, user);
    HTTP.post.restore();
}
方法:

Meteor.methods({
    'sendData'({ payload }) {
      const appKey = Meteor.settings.myapp.appKey;
      if (!appKey) throw new Meteor.Error('No app key found in Meteor.settings.');

      const withAppKey = Object.assign({ appKey }, payload);

      HTTP.post(getRemoteUrl(), {
        data: withAppKey,
      }, (err, res) => {
        if (err) console.log('err', err);
        else console.log('res', res);
      });
    },
  });

如果您使用meteor 1.3,您至少可以使用以下工具运行完整的应用程序测试:

meteor test --full-app --settings my.settings.json --driver-package <driverpackage>
流星测试——完整应用——设置my.settings.json——驱动程序包

您是否尝试过流星测试之类的设置您的.settings.file.json?