我尝试使用下面的代码模拟Template.__create__
,但我仍然收到错误。
在package.js
中Package.describe({
name: 'robwatkin:mypackage',
});
Package.onUse(function(api) {
api.versionsFrom('1.1.0.2');
api.use('meteor-platform');
api.use('iron:router');
api.use('reactive-var');
api.use('templating');
});
Package.onTest(function(api) {
api.use('tinytest');
api.addFiles('mocks.js');
api.use('robwatkin:mypackage');
api.addFiles('tests.js');
});
在mocks.js中
Template = {
__create__: function() {console.log('STUB Template.__create__')}
};
在tests.js
中Tinytest.add('example', function (test) {
test.equal(true, true);
});
给出
Uncaught TypeError: Template.__create__ is not a function(anonymous function) @ layout.js:286(anonymous function) @ iron_layout.js?d62e492972d7f97328c54d2ba052d5adf0cf0d9a:534(anonymous function) @ iron_layout.js? d62e492972d7f97328c54d2ba052d5adf0cf0d9a:541
如果我发表评论
,它的工作正常api.use('robwatkin:mypackage');
由于