簡體   English   中英

Meteor.js異步幫助:在服務器上設置測試數據

[英]Meteor.js Async Help: Setting Up Test Data on the Server

我正在嘗試為使用Velocity以及Cucumber和Jasmine的環境設置一些測試數據。

我正在嘗試做一些非常正常的事情-事先在數據庫中設置一些測試數據。

我遇到了一些問題,這些問題似乎與Meteor中異步行為的工作方式有關。 我習慣於使用Promises,但在該平台上似乎並不是一個選擇。

我想要:

  • 創建一個用戶
  • 查找該用戶
  • console.log查找結果

下面是我的tests/cucumber/features文件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)

好,找出答案。 也許這會幫助別人。 發現不需要包裹在Meteor.wrapAsync

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM