我一直在使用節點並使用誓言來編寫測試。寫入異步Vows.js錯誤測試
var vows = require('vows');
var assert = require('assert');
var boardData = require('../lib/data/BoardData.js');
vows.describe('Loading provinces and Boundries for').addBatch({
'version': {
'2008E5-1':{
topic: function() { boardData.createBoard("2008E5",this.callback); },
'exists': function (err,provs,bounds) { assert.ok(true); }
}/*,
'2008E5-2': {
topic: function() { boardData.createBoard("2008E5",this.callback); },
'exists': function (err,provs,bounds) { assert.ok(true); }
}*/
}
}).export(module);
當我運行此代碼時,我得到預期的結果。 當我取消評論部分的註釋時,注意到兩個已成功完成,但可以通過放置console.log(「foo」)來發現這是第二個。在適當的位置。
·· ✓ OK » 2 honored (0.067s)
·
✗ Errored » callback not fired
in version 2008E5-1
in Loading provinces and Boundries for
in undefined
這一定是我缺少某些東西或缺乏對某些事物的理解,但我無法弄清楚。誰能幫我?提前致謝!
它看起來像boardData.createBoard不調用回調。 –
當代碼中有註釋運行時,它會調用它。使用一個簡單的console.log(「foo」);在它的回調錶演中。 'exists':function(err,provs,bounds){console.log(「foo」); assert.ok(真); } –