Files
socket.io/test/node.js
Damien Arrachequesne 65516836b2 feat: add autoUnref option
With autoUnref set to true (default: false), the Engine.IO client will
allow the program to exit if there is no other active timer/socket in
the event system.

Note: the 'xmlhttprequest-ssl' package has been copied in the contrib/
directory, until the change is merged upstream

Related: https://github.com/socketio/engine.io-client/issues/653
2021-03-03 10:12:40 +01:00

30 lines
823 B
JavaScript

const path = require("path");
const { exec } = require("child_process");
describe("autoRef option", () => {
const fixture = filename =>
process.execPath + " " + path.join(__dirname, "fixtures", filename);
it("should stop once the timer is triggered", done => {
exec(fixture("unref.js"), done);
});
it("should stop once the timer is triggered (polling)", done => {
exec(fixture("unref-polling-only.js"), done);
});
it("should stop once the timer is triggered (websocket)", done => {
exec(fixture("unref-websocket-only.js"), done);
});
it("should not stop with autoUnref set to false", done => {
const process = exec(fixture("no-unref.js"), () => {
done(new Error("should not happen"));
});
setTimeout(() => {
process.kill();
done();
}, 1000);
});
});