Skip to content

Commit 5a20937

Browse files
committed
Some more minor cleanup
1 parent dc864d7 commit 5a20937

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

test/test-runner.js

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,6 @@ async function runMochaAsync(mocha) {
7070
return new Promise(resolve => mocha.run(resolve));
7171
}
7272

73-
async function maybeExtractMochaStatsDump(msg) {
74-
if (msg.args().length == 1 && msg.text().startsWith("{")) {
75-
const arg = await msg.args()[0].jsonValue();
76-
let obj;
77-
try {
78-
obj = JSON.parse(arg);
79-
} catch (e) {
80-
return;
81-
}
82-
if (obj.hasOwnProperty("stats")) {
83-
return obj;
84-
}
85-
}
86-
}
87-
8873
const PORT = process.env.PORT ?? 50123;
8974
const OPEN_DEVTOOLS = !!process.env.OPEN_DEVTOOLS;
9075

@@ -107,11 +92,12 @@ async function getNumFailingTestsInPuppeteer() {
10792
}
10893
});
10994

95+
// If we want DevTools open, wait for a second here so DevTools can load.
96+
// Otherwise we might run past `debugger` statements.
11097
if (OPEN_DEVTOOLS) {
111-
// If we want DevTools open, wait for a second here so DevTools can load.
112-
// Otherwise we might run past `debugger` statements.
11398
await new Promise(resolve => setTimeout(resolve, 1000));
11499
}
100+
115101
const app = Express();
116102
app.use("/", Express.static("../"));
117103
const server = app.listen(PORT);
@@ -125,9 +111,10 @@ async function getNumFailingTestsInPuppeteer() {
125111
suitePaths.push(${JSON.stringify(testFile)});
126112
`);
127113
}
128-
const script = document.createElement("script");
114+
129115
// Create a promise that resolves once mocha is done running.
130116
// This way we can block this `evaluate` call until mocha is done.
117+
const script = document.createElement("script");
131118
script.innerHTML = `
132119
self.mochaRun = new Promise(resolve => mocha.run(resolve));`;
133120
document.body.append(script);
@@ -148,3 +135,18 @@ async function getNumFailingTestsInPuppeteer() {
148135
}
149136
return numFailures;
150137
}
138+
139+
async function maybeExtractMochaStatsDump(msg) {
140+
if (msg.args().length == 1 && msg.text().startsWith("{")) {
141+
const arg = await msg.args()[0].jsonValue();
142+
let obj;
143+
try {
144+
obj = JSON.parse(arg);
145+
} catch (e) {
146+
return;
147+
}
148+
if (obj.hasOwnProperty("stats")) {
149+
return obj;
150+
}
151+
}
152+
}

0 commit comments

Comments
 (0)