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
Unit testing meteor Cumber测试服务器。步骤定义中的调用错误:找不到方法[404]_Unit Testing_Meteor_Cucumber - Fatal编程技术网

Unit testing meteor Cumber测试服务器。步骤定义中的调用错误:找不到方法[404]

Unit testing meteor Cumber测试服务器。步骤定义中的调用错误:找不到方法[404],unit-testing,meteor,cucumber,Unit Testing,Meteor,Cucumber,我是流星黄瓜的新手,我正在尝试做一个基本的测试 检查新用户 这是步骤定义代码 this.Given(/^I是新用户$/,函数(){ 调用('fixtures/reset')。然后(function(){ 调用('fixtures/seedData'); }); }); 我明白了 这是package.js Package.description({ 名称:'固定装置', 版本:“0.0.1”, 摘要:“”, git:“”, 文档:空, debugOnly:正确 }); 包.onUse(函数(ap

我是流星黄瓜的新手,我正在尝试做一个基本的测试
检查新用户
这是步骤定义代码

this.Given(/^I是新用户$/,函数(){
调用('fixtures/reset')。然后(function(){
调用('fixtures/seedData');
});
});
我明白了

这是package.js

Package.description({
名称:'固定装置',
版本:“0.0.1”,
摘要:“”,
git:“”,
文档:空,
debugOnly:正确
});
包.onUse(函数(api){
api.versionFrom('1.2.1');
api.use('ecmascript');
addFiles(['fixtures.js'],['server']);
});
我不明白为什么此代码失败

它基于

为什么您有一个测试包?那没必要。在Meteor应用文件夹的根级别,创建一个名为“tests”的目录。我的结构如下所示:

tests
└── cucumber
    ├── features
    │   ├── artist
    │   │   ├── artist-login.feature
    │   │   └── step_definitions
    │   │       └── artist-login.js
    │   ├── support
    │   │   └── hooks.js
    │   └── viewer
    └── fixtures
        └── artist-fixtures.js
在fixtures文件中不需要任何闭包。这是我的:

Meteor.methods({
  'reset': function () {
    Meteor.users.remove({});
  },

  'createTestAccount': function () {
    Accounts.createUser({
      email: 'test@user.com',
      password: 'test123',
      profile: {
        firstName: 'Test',
        lastName: 'User'
      }
    });
  },

  'isLoggedIn': function () {
    return !!Meteor.userId();
  }
});

如果您正在编写Meteor软件包并希望对其进行测试,请使用TinyTest。

您的解决方案有效。我认为一个fixture包可以与jasmine unit testsI共享这些方法。我遵循了相同的教程,并最终遇到了相同的问题。我已经复制了您的结构并删除了Meteor.methods的代码,但是我得到了一个引用错误:Meteor没有定义,我的测试甚至不会开始运行。如何让Meteor在测试装置中可用?@macasas暂缓,xolvio:cucumber现在已被弃用,Meteor 1.3将拥有自己的官方测试平台。
Meteor.methods({
  'reset': function () {
    Meteor.users.remove({});
  },

  'createTestAccount': function () {
    Accounts.createUser({
      email: 'test@user.com',
      password: 'test123',
      profile: {
        firstName: 'Test',
        lastName: 'User'
      }
    });
  },

  'isLoggedIn': function () {
    return !!Meteor.userId();
  }
});