improve electron tests (avoid errors in github workflows) (#2977)

Fix electron tests failing sometimes in github workflow.
This commit is contained in:
Karsten Hassel 2022-12-12 21:43:22 +01:00 committed by GitHub
parent 3124b0a9c5
commit 2fec314ff5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 11 deletions

View File

@ -51,6 +51,7 @@ Special thanks to: @rejas, @sdetweil, @MagMar94
- Possibility to change FontAwesome class in calendar, so icons like `fab fa-facebook-square` works. - Possibility to change FontAwesome class in calendar, so icons like `fab fa-facebook-square` works.
- Fix cors problems with newsfeed articles (as far as possible), allow disabling cors per feed with option `useCorsProxy: false` (#2840) - Fix cors problems with newsfeed articles (as far as possible), allow disabling cors per feed with option `useCorsProxy: false` (#2840)
- Tests not waiting for the application to start and stop before starting the next test - Tests not waiting for the application to start and stop before starting the next test
- Fix electron tests failing sometimes in github workflow
- Fixed gap in clock module when displayed on the left side with displayType=digital - Fixed gap in clock module when displayed on the left side with displayType=digital
## [2.21.0] - 2022-10-01 ## [2.21.0] - 2022-10-01

View File

@ -10,10 +10,14 @@ exports.startApplication = async (configFilename, systemDate = null, electronPar
process.env.TZ = "GMT"; process.env.TZ = "GMT";
jest.retryTimes(3); jest.retryTimes(3);
global.electronApp = await electron.launch({ args: electronParams }); global.electronApp = await electron.launch({ args: electronParams });
expect(global.electronApp);
if ((await global.electronApp.windows().length) === 1) { await global.electronApp.firstWindow();
global.page = await global.electronApp.firstWindow();
for (const win of global.electronApp.windows()) {
const title = await win.title();
expect(["MagicMirror²", "DevTools"]).toContain(title);
if (title === "MagicMirror²") {
global.page = win;
if (systemDate) { if (systemDate) {
await global.page.evaluate((systemDate) => { await global.page.evaluate((systemDate) => {
Date.now = () => { Date.now = () => {
@ -21,8 +25,7 @@ exports.startApplication = async (configFilename, systemDate = null, electronPar
}; };
}, systemDate); }, systemDate);
} }
expect(await global.page.title()).toBe("MagicMirror²"); }
expect(await global.page.isVisible("body")).toBe(true);
} }
}; };