【发布时间】: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