Created
October 29, 2021 14:23
-
-
Save el3um4s/64990fcd4c3dcd5f3f4e1c8be4d428b7 to your computer and use it in GitHub Desktop.
MEDIUM - Ho to Test Electron Apps - 03
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const windowState = await electronApp.evaluate(async ({ BrowserWindow }) => { | |
const mainWindow = BrowserWindow.getAllWindows()[0]; | |
const getState = () => ({ | |
isVisible: mainWindow.isVisible(), | |
isDevToolsOpened: mainWindow.webContents.isDevToolsOpened(), | |
isCrashed: mainWindow.webContents.isCrashed(), | |
}); | |
return new Promise((resolve) => { | |
if (mainWindow.isVisible()) { | |
resolve(getState()); | |
} else { | |
mainWindow.once("ready-to-show", () => | |
setTimeout(() => resolve(getState()), 0) | |
); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment