From cfc0bcd5ad1d3470a42547d6ab3b15f852c11b2d Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Fri, 18 Jun 2021 21:39:55 +0200 Subject: [PATCH] workaround for dev_console test using getWindowCount --- CHANGELOG.md | 1 + js/electron.js | 5 +++++ tests/e2e/dev_console.js | 36 +++++++++++++++++------------------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad819d31..54cac74e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ Special thanks to the following contributors: @B1gG, @codac, @ezeholz, @khassel, - Fix calendar debug check - Really run prettier over all files - Fix logger.js after jest changes +- Workaround for dev_console test using getWindowCount. ## [2.15.0] - 2021-04-01 diff --git a/js/electron.js b/js/electron.js index 6c2f44a7..a834f7ab 100644 --- a/js/electron.js +++ b/js/electron.js @@ -63,6 +63,11 @@ function createWindow() { // Open the DevTools if run with "npm start dev" if (process.argv.includes("dev")) { + if (process.env.JEST_WORKER_ID !== undefined) { + // if we are running with jest + var devtools = new BrowserWindow(electronOptions); + mainWindow.webContents.setDevToolsWebContents(devtools.webContents); + } mainWindow.webContents.openDevTools(); } diff --git a/tests/e2e/dev_console.js b/tests/e2e/dev_console.js index 26510ea4..2a607e5b 100644 --- a/tests/e2e/dev_console.js +++ b/tests/e2e/dev_console.js @@ -31,25 +31,23 @@ describe("Development console tests", function () { }); }); - // describe("With 'dev' commandline argument", function () { - // beforeAll(function () { - // return helpers - // .startApplication({ - // args: ["js/electron.js", "dev"] - // }) - // .then(function (startedApp) { - // app = startedApp; - // }); - // }); + describe("With 'dev' commandline argument", function () { + beforeAll(function () { + return helpers + .startApplication({ + args: ["js/electron.js", "dev"] + }) + .then(function (startedApp) { + app = startedApp; + }); + }); - // afterAll(function () { - // return helpers.stopApplication(app); - // }); + afterAll(function () { + return helpers.stopApplication(app); + }); - // it("should open dev console when provided", async function () { - // expect(await app.client.getWindowCount()).toBe(2); - // await app.client.waitUntilWindowLoaded(); - // return expect(await app.browserWindow.isDevToolsOpened()).toBe(true); - // }); - // }); + it("should open dev console when provided", async function () { + expect(await app.client.getWindowCount()).toBe(2); + }); + }); });