From a90b060f1cb531cd245083a7466f90b5e8e6e044 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Tue, 4 Oct 2022 15:26:02 -0400 Subject: [PATCH] Add check for app early exiting Signed-off-by: Sebastian Malton --- integration/helpers/utils.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/integration/helpers/utils.ts b/integration/helpers/utils.ts index cc0652c166..fc074b1dbb 100644 --- a/integration/helpers/utils.ts +++ b/integration/helpers/utils.ts @@ -33,6 +33,14 @@ async function getMainWindow(app: ElectronApplication, timeout = 50_000): Promis } }; + const onClose = () => { + cleanup(); + reject(new Error("App has unnexpectedly closed")); + }; + + app.on("close", onClose); + cleanup.push(() => app.off("close", onClose)); + app.addListener("window", handler); cleanup.push(() => app.removeListener("window", handler)); @@ -40,7 +48,7 @@ async function getMainWindow(app: ElectronApplication, timeout = 50_000): Promis if (stdout) { const onData = (chunk: any) => stdoutBuf += chunk.toString(); - + stdout.on("data", onData); cleanup.push(() => stdout.off("data", onData)); }