When the Server#createSession() method fails due to a timeout error (selenium hub server not responding), leadfoot does not dispose something and hence the mocha process does not exit.
Reproduce:
create a http server that listens for connections but does not respond to requests
create a session and connect to that http server
code for http server (server.js):
var http = require("http");
var server = http.createServer(() => undefined);
server.listen(4444);
code for leadfoot test (test.js):
var leadfoot = require("@theintern/leadfoot");
describe("foo", function() {
this.timeout(10E3);
it("should dispose normally if the hub is not present", async () => {
var host = "localhost";
var port = 4444;
var server = new leadfoot.Server(`http://${host}:${port}/wd/hub`, { timeout: 3000 });
try {
await server.createSession({ browserName: "chrome" });
} catch (error) {
// try to dispose anything we can get our hands on
const sessions = await server.getSessions();
await Promise.all(sessions.map(async (s) => {
await s.quit();
await server.deleteSession(s.sessionId);
}));
}
});
})
Now, run both node server.js and mocha test.js. The test process hangs indefinitely.
When the
Server#createSession()
method fails due to a timeout error (selenium hub server not responding), leadfoot does not dispose something and hence the mocha process does not exit.Reproduce:
code for http server (server.js):
code for leadfoot test (test.js):
Now, run both
node server.js
andmocha test.js
. The test process hangs indefinitely.