私はnode.jsテストにまったく慣れていません。多分あなたが私を助けてくれるかもしれません.vowsとtobiを使用して、エクスプレスWebアプリケーションの多かれ少なかれ簡単なテストを行いたいです(たとえば、ログインルートが機能するかどうかのテスト)
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 での非同期スタイルのプログラミングにもかなり慣れていません。