【问题标题】:Meteor.js Async Help: Setting Up Test Data on the ServerMeteor.js 异步帮助:在服务器上设置测试数据
【发布时间】:2015-04-25 02:46:10
【问题描述】:

我正在尝试为使用 Velocity 以及 Cucumber 和 Jasmine 的环境设置一些测试数据。

我正在尝试做一些非常正常的事情 - 事先在数据库中设置一些测试数据。

我遇到了一些似乎与 Meteor 中异步行为的工作方式有关的问题。我习惯使用 Promises,但它们似乎不是这个平台上的一个选项。

我想:

  • 创建用户
  • 查找该用户
  • console.log 查找的结果

下面是我在tests/cucumber/features的夹具文件中的一些代码

  // make a user - it correctly writes to my cucumber db
  Meteor.wrapAsync(
    Accounts.createUser({
      email: "harry@example.com",
      password: "password"
    })
  )

  // Do a find for that user
  var theUser = Meteor.wrapAsync(Meteor.users.findOne({emails: {$elemMatch: {address: "harry@example.com"}}}))

  // log out that user. The console returns `[Function]` rather than the result of the find. How do I get the result of the find?
  console.log(theUser)

【问题讨论】:

    标签: javascript asynchronous meteor velocity


    【解决方案1】:

    好的,找到答案了。也许这会帮助别人。 find 不需要包裹在 Meteor.wrapAsync

    【讨论】:

      猜你喜欢
      • 2021-01-06
      • 2011-02-15
      • 1970-01-01
      • 2011-10-20
      • 2014-12-03
      • 2020-12-15
      • 1970-01-01
      • 2010-10-14
      • 1970-01-01
      相关资源
      最近更新 更多