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