我正在尝试为使用 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/