2
我一直在嘗試學習如何使用expresso進行單元測試,並難以從異步貓鼬數據庫調用中獲取結果。似乎測試不會等待異步調用返回,所以我的斷言總是失敗。我該如何測試與expresso貓鼬異步調用
"get tasks" : (beforeExit, assert) ->
tasks = null
Task.find {}, (err, result) ->
if not err
console.log 'results'
tasks = result
else
console.log 'error' + err
should.not(err)
beforeExit ->
tasks.should.not(null)
看起來這可能是掛在貓鼬連接呼叫以及
db = mongoose.connect config.connStr