我对 node.js 测试完全陌生,也许你可以帮助我:我想使用 vows 和 tobi 为我的 express 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 中的异步编程风格也很陌生。