From 62f89bdaf42914956e0a876a1c4c58decdff6fc7 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Tue, 4 Oct 2022 09:02:51 -0400 Subject: [PATCH] Attempt to fix traking stdout Signed-off-by: Sebastian Malton --- integration/helpers/utils.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/integration/helpers/utils.ts b/integration/helpers/utils.ts index 2ba4a11c46..9afe4e7819 100644 --- a/integration/helpers/utils.ts +++ b/integration/helpers/utils.ts @@ -22,8 +22,7 @@ export const appPaths: Partial> = { async function getMainWindow(app: ElectronApplication, timeout = 50_000): Promise { return new Promise((resolve, reject) => { const cleanup = disposer(); - const stdoutBuffer = Buffer.from(""); - const stdoutStream = new Writable(stdoutBuffer); + let stdoutBuf = ""; const handler = (page: Page) => { console.log(`Page opened: ${page.url()}`); @@ -37,12 +36,18 @@ async function getMainWindow(app: ElectronApplication, timeout = 50_000): Promis app.addListener("window", handler); cleanup.push(() => app.removeListener("window", handler)); - app.process().stdout?.pipe(stdoutStream); - cleanup.push(() => app.process().stdout?.unpipe(stdoutStream)); + const { stdout } = app.process(); + + if (stdout) { + const onData = (chunk: any) => stdoutBuf += chunk.toString(); + + stdout.on("data", onData); + cleanup.push(() => stdout.off("data", onData)); + } const timeoutId = setTimeout(() => { cleanup(); - console.log(stdoutBuffer.toString("utf8")); + console.log(stdoutBuf); reject(new Error(`Lens did not open the main window within ${timeout}ms`)); }, timeout);