-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Expand file tree
/
Copy pathnode.ts
More file actions
46 lines (39 loc) · 1.23 KB
/
node.ts
File metadata and controls
46 lines (39 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const path = require("path");
const { exec } = require("child_process");
describe("autoUnref option", function () {
before(function () {
if (process.env.WDIO_WORKER_ID !== undefined) {
return this.skip();
}
});
const fixture = (filename) =>
process.execPath + " " + path.join(__dirname, "fixtures", filename);
it("should stop once the timer is triggered", (done) => {
exec(fixture("unref.ts"), done);
});
it("should stop once the timer is triggered (even when trying to reconnect)", (done) => {
exec(fixture("unref-during-reconnection.ts"), done);
});
it("should stop once the timer is triggered (polling)", (done) => {
exec(fixture("unref-polling-only.ts"), done);
});
it("should stop once the timer is triggered (websocket)", (done) => {
exec(fixture("unref-websocket-only.ts"), done);
});
it("should not stop with autoUnref set to false", (done) => {
let doneCalled = false;
const process = exec(fixture("no-unref.ts"), () => {
if (!doneCalled) {
doneCalled = true;
done(new Error("should not happen"));
}
});
setTimeout(() => {
process.kill();
if (!doneCalled) {
doneCalled = true;
done();
}
}, 100);
});
});