FayeJS客户端在Mocha测试中不断开连接

时间:2019-06-03 08:03:19

标签: testing websocket mocha faye

我与Mocha进行了集成测试,以验证Fay Websocket连接:

it('should allows clients to open ws', function (done) {
    const cli = new FayeClient(`http://localhost:${config.port}/${config.root}/ws`);
    should.exist(cli);
    const subscription = cli.subscribe('/foo', msg => {
        should.exist(msg);
        msg.should.be.deep.equal({ foo: 'bar' });
        subscription.cancel();
        cli.disconnect();
        return done();
    });
});

已正确调用了订阅回调,消息检查通过了,但是从未调用done,因此测试从未结束。如果我删除订阅部分并仅保留存在检查,则测试将正确完成。

我应该如何终止客户端?

0 个答案:

没有答案
相关问题