我正在嘗試爲我的快速應用程序編寫一些基於Vows的測試。server.close()不適用於Vow拆解
這裏的測試來源:
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
,都無濟於事。
我在Node.js 4.2.0的Windows x64版本上,我使用的是[email protected]
和[email protected]
。
任何想法如何讓我的測試停止掛?
檢查結果在這裏同樣的問題,測試建立在Travis永遠運行。你找到解決方案嗎? –
@FernandoPiancastelli我從來沒有找到一個合適的解決方案,但作爲一個骯髒的黑客,調用'主題'對象上的'.unref()'固定「這個。我懷疑有某個地方有bug,可能在Node core ... – strugee