1
我對node.js測試完全陌生,也許你可以幫我解決: 我想對使用誓言和tobi的express webapp做一些或多或少的簡單測試(例如測試如果登錄路由的工作原理)使用Vows和Tobi進行Webapp測試
var vows = require('vows');
var assert = require('assert');
var tobi = require('tobi');
var browser = tobi.createBrowser(8080, 'localhost');
vows.describe('mytest').addBatch({
'GET /': {
topic: function() {
browser.get("/", this.callback);
},
'has the right title': function(res, $) {
$('title').should.equal('MyTitle');
}
}
}).export(module);
,我得到這個:
♢ mytest
GET/
✗ has the right title
» expected { '0':
{ _ownerDocument:
[....lots of stuff, won't paste it all.....]
Entity: [Function: Entity],
EntityReference: [Function: EntityReference] } },
selector: ' title' } to equal 'MyTitle' // should.js:295
✗ Broken » 1 broken (0.126s)
我不能認識到什麼是從這個輸出錯誤的,但我猜它的人做回調。我也是node.js中異步編程風格的新手。
這個代碼拋出了同樣的錯誤:( – toxinlabs 2012-01-10 18:36:35
誓言是一種奇怪的,如果你在你的回調一個參數,第一個參數的東西調用它,它會認爲這是一個錯誤,告訴你有一個錯誤如果你有多個它認爲你想自己處理錯誤並且不會拋出錯誤嘗試在你的原始代碼中添加一個額外的錯誤參數 – fent 2012-01-10 19:50:28
這並沒有很好的記錄在誓言中, – fent 2012-01-10 19:51:07