I wrote an integration test with Mocha to verify a Fay websocket connection:
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();
});
});
The subscription callback is correctly called, the message check passes but done
is never called and so the test never ends. If I remove the subscription part and leave only the existence check, the test completes correctly.
How should I terminate the client?
Aucun commentaire:
Enregistrer un commentaire