Skip to content

Instantly share code, notes, and snippets.

@el3um4s
Created October 29, 2021 14:23
Show Gist options
  • Save el3um4s/64990fcd4c3dcd5f3f4e1c8be4d428b7 to your computer and use it in GitHub Desktop.
Save el3um4s/64990fcd4c3dcd5f3f4e1c8be4d428b7 to your computer and use it in GitHub Desktop.
MEDIUM - Ho to Test Electron Apps - 03
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