我正在尝试为我的普通 Express 应用程序编写一些基于 Vows 的测试。
这是测试源:
var vows = require('vows');
var assert = require('assert');
var startApp = require('./lib/start-app.js');
var suite = vows.describe('tournaments');
suite.addBatch({
"When we setup the app": {
topic: function() {
return startApp();
},
teardown: function(topic) {
if (topic && topic.close) {
topic.close();
}
},
"it works": function(topic) {
assert.isObject(topic);
}
}
});
suite.run();
这是start-app.js
:
var app = require('../../app.js');
function start() {
var server = app.listen(56971, 'localhost');
return server;
}
module.exports = start;
app.js
导出一个常规的 Express.js 应用程序,使用express()
.
问题是,每当我运行测试时,topic.close()
在拆卸功能中不起作用,并且测试在成功后永远挂起。我试过在网上搜索并添加很多很多console.log
s,但都无济于事。
我在 Node.js 4.2.0 的 Windows x64 版本上,我正在使用assert@1.3.0
和vows@0.8.1
.
知道如何让我的测试停止挂起吗?