javascript - Meteor.js 异步帮助 : Setting Up Test Data on the Server

标签 javascript asynchronous meteor velocity

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

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

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

我想要:

  • 创建用户
  • 查找该用户
  • 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)

最佳答案

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

关于javascript - Meteor.js 异步帮助 : Setting Up Test Data on the Server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29854661/

相关文章:

Javascript : Identify whether it is a desktop Linux or Android

javascript - mup 部署的应用程序中的 .meteor 目录在哪里?

javascript - p :autocomplete completemethod isn't fired with copy-pate with mouse events

javascript - 将鼠标悬停在 id 上时会更改图像

java - Jersey 的多线程

java - 异步 Servlet 不在单独的线程中执行异步任务

asynchronous - node.js 的最佳控制流模块是什么?

javascript - 使用 html5 导出按钮 meteor 表格导出数据

javascript - 巴巴图斯 :star-rating error in meteor js

javascript - jQuery/AJAX - 单击按钮时将内容加载到 div 中?