Meteor.js:在使用Chimp测试时使用server.call [英] Meteor.js: Using server.call when testing with Chimp

查看:313
本文介绍了Meteor.js:在使用Chimp测试时使用server.call的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写特征测试时遇到触发方法调用的问题。我实际上没有在chimp终端日志中给出错误,但server.call行是突出显示失败的地方。我相信这可能与应用程序的文件夹结构有关(我基于)活版)或定义并随后触发呼叫的顺序。当我将方法调用移动到我的main.js文件(在应用程序的根文件夹),它工作没有问题。

I'm having an issue triggering method calls while writing feature tests. I'm not actually given an error in the chimp terminal log, but the server.call line is where the failure is highlighted. I believe this might be related to the folder structure of the app (which I've loosely based on Letterpress) or the order in which the call is defined and then triggered. When I move the method call out to my main.js file (in the root folder of the app), it works without a problem.

hooks.js 路径:/app/tests/cucumber/features/support/hooks.js

hooks.js path: /app/tests/cucumber/features/support/hooks.js

(function(){
    module.exports = function() {
        this.Before(function() {
            console.log("server calling");
            server.call("fixtures/resetUsers"); //test stops here
        });
    };
})();

fixtures.js /app/packages/fixtures/fixtures.js

fixtures.js /app/packages/fixtures/fixtures.js

(function(){
    'use strict';

    Meteor.methods({
        "fixtures/resetUsers": function() {
            Meteor.users.remove({});
        }
    });
})();

package.js /app/packages/fixtures/packages.js

package.js /app/packages/fixtures/packages.js

Package.describe({
    name: 'forum:fixtures',
    version: '0.0.1',
    summary: '',
    debugOnly: true
});

Package.onUse(function(api) {
    api.versionsFrom('1.2.1');
    api.use('ecmascript');
    api.addFiles('fixtures.js', 'server');
});



注意:我原来没有夹具文件夹包裹在packages文件夹t工作),但遇到由@ Xolv.io的此帖,Chimp.js的开发人员建议这样做。

Note: I originally didn't have the fixtures folder wrapped in the packages folder (it still didn't work then) but came across this post by @Xolv.io, the developers of Chimp.js who advised to do so.

推荐答案

使用新的chimp,您只需使用:

with the new chimp, you can just use:

server.execute(function() {
  // code you put here will run on the server
});

检查此存储库的示例:
https://github.com/xolvio/automated-testing-best-practices/

Check this repository for examples: https://github.com/xolvio/automated-testing-best-practices/

这篇关于Meteor.js:在使用Chimp测试时使用server.call的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆