Skip to content

Commit 21bbee4

Browse files
authored
init progressbar dependencies within host start to avoid execution in a browser context (#18554)
1 parent 49a73a9 commit 21bbee4

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/harness/parallel/host.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ namespace Harness.Parallel.Host {
2828
}
2929

3030
export function start() {
31+
initializeProgressBarsDependencies();
3132
console.log("Discovering tests...");
3233
const discoverStart = +(new Date());
3334
const { statSync }: { statSync(path: string): { size: number }; } = require("fs");
@@ -254,14 +255,26 @@ namespace Harness.Parallel.Host {
254255
return;
255256
}
256257

257-
const Mocha = require("mocha");
258-
const Base = Mocha.reporters.Base;
259-
const color = Base.color;
260-
const cursor = Base.cursor;
261-
const readline = require("readline");
262-
const os = require("os");
263-
const tty: { isatty(x: number): boolean } = require("tty");
264-
const isatty = tty.isatty(1) && tty.isatty(2);
258+
let Mocha: any;
259+
let Base: any;
260+
let color: any;
261+
let cursor: any;
262+
let readline: any;
263+
let os: any;
264+
let tty: { isatty(x: number): boolean };
265+
let isatty: boolean;
266+
267+
function initializeProgressBarsDependencies() {
268+
Mocha = require("mocha");
269+
Base = Mocha.reporters.Base;
270+
color = Base.color;
271+
cursor = Base.cursor;
272+
readline = require("readline");
273+
os = require("os");
274+
tty = require("tty");
275+
isatty = tty.isatty(1) && tty.isatty(2);
276+
}
277+
265278
class ProgressBars {
266279
public readonly _options: Readonly<ProgressBarsOptions>;
267280
private _enabled: boolean;

0 commit comments

Comments
 (0)