2016-07-07 10 views
1

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); 
     }); 
    }, 
    }); 
+0

あなたは 'meteor test --settings your.settings.file.json'のようなものを試しましたか? – Samuel

答えて

1

あなたは流星1.3を使用する場合は、少なくとも実行することができます

meteor test --full-app --settings my.settings.json --driver-package <driverpackage> 

:との完全なアプリケーションのテスト

関連する問題