Skip to content

Commit 5fd1b6f

Browse files
committed
further cleanup
1 parent 10ba50a commit 5fd1b6f

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

tests/run.mjs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#! /usr/bin/env node
22
/* eslint-disable-next-line no-unused-vars */
33
import serve from "./server.mjs";
4-
import { Builder, Capabilities} from "selenium-webdriver";
4+
import { Builder, Capabilities } from "selenium-webdriver";
55
import commandLineArgs from "command-line-args";
66
import commandLineUsage from "command-line-usage";
77

@@ -63,6 +63,7 @@ switch (BROWSER) {
6363
printHelp(`Invalid browser "${BROWSER}", choices are: "safari", "firefox", "chrome", "edge"`);
6464
}
6565
}
66+
6667
process.on("unhandledRejection", (err) => {
6768
console.error(err);
6869
process.exit(1);
@@ -76,9 +77,7 @@ const PORT = options.port;
7677
const server = await serve(PORT);
7778

7879
async function testEnd2End() {
79-
const driver = await new Builder()
80-
.withCapabilities(capabilities)
81-
.build();
80+
const driver = await new Builder().withCapabilities(capabilities).build();
8281
let results;
8382
try {
8483
console.log("Preparing JetStream");
@@ -90,7 +89,8 @@ async function testEnd2End() {
9089
if (globalThis?.JetStream?.isReady)
9190
callback()
9291
});
93-
results = await benchmarkResults(driver)
92+
results = await benchmarkResults(driver);
93+
// FIXME: validate results;
9494
} finally {
9595
console.log("\nTests complete!");
9696
driver.quit();
@@ -112,33 +112,31 @@ async function benchmarkResults(driver) {
112112
});
113113
JetStream.start();
114114
});
115-
116115
await new Promise(resolve => pollIncrementalResults(driver, resolve));
117116
const resultString = await driver.executeScript(() => {
118-
if (globalThis.JetStreamDone)
119-
return JSON.stringify(JetStream.resultsObject());
117+
return JSON.stringify(JetStream.resultsObject());
120118
});
121119
return JSON.parse(resultString);
122120
}
123121

124122
const UPDATE_INTERVAL = 250;
125123
async function pollIncrementalResults(driver, resolve) {
126-
const internalId = setInterval(async function logResult() {
124+
const intervalId = setInterval(async function logResult() {
127125
const {done, results} = await driver.executeAsyncScript((callback) => {
128126
callback({
129127
done: globalThis.JetStreamDone,
130128
results: JSON.stringify(globalThis.JetStreamResults.splice(0, Infinity))
131129
});
132130
});
133-
JSON.parse(results).forEach(logBenchmarkResult);
131+
JSON.parse(results).forEach(logIncrementalResult);
134132
if (done) {
135-
clearInterval(internalId);
133+
clearInterval(intervalId);
136134
resolve()
137135
}
138136
}, UPDATE_INTERVAL)
139137
}
140138

141-
function logBenchmarkResult(benchmarkResult) {
139+
function logIncrementalResult(benchmarkResult) {
142140
console.log(benchmarkResult.name, benchmarkResult.results)
143141
}
144142

0 commit comments

Comments
 (0)