server.close()不能在VOW中拆卸

我正在尝试为我的快速应用程序编写一些基于Vows的testing。

这里是testing来源:

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()创build。

问题是,无论何时运行testing, topic.close()topic.close()函数中都不起作用,并且testing成功后永远挂起。 我试过在网上search并添加很多console.log ,都无济于事。

我在Node.js 4.2.0的Windows x64版本上,我使用assert@1.3.0vows@0.8.1

任何想法如何让我的testing停止挂?

以下是我在一个我正在贡献的项目中解决问题的方法:closures服务器的最后一批。

 suite.addBatch({ 'terminate server': { topic: function() { server.close(this.callback); // this is a regular node require(`http`) server, reused in several batches }, 'should be listening': function() { /* This test is necessary to ensure the topic execution. * A topic without tests will be not executed */ assert.isTrue(true); } } }).export(module); 

在添加此testing之前,套件永远不会结束执行。 你可以在https://travis-ci.org/fmalk/node-static/builds/90381188查看结果