From 8a92b65fd373d55bbca4f51308a7a247be7476a0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 10 Jan 2020 04:50:30 +0900 Subject: [PATCH] test: retry for a few flaky tests (#21658) --- spec-main/api-web-contents-spec.ts | 7 ++++++- spec-main/visibility-state-spec.ts | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/spec-main/api-web-contents-spec.ts b/spec-main/api-web-contents-spec.ts index 86a8e1692f24..403c01e7e904 100644 --- a/spec-main/api-web-contents-spec.ts +++ b/spec-main/api-web-contents-spec.ts @@ -1122,7 +1122,12 @@ describe('webContents module', () => { { name: 'did-fail-load', url: '/net-error' } ] for (const e of events) { - it(`should not crash when invoked synchronously inside ${e.name} handler`, async () => { + it(`should not crash when invoked synchronously inside ${e.name} handler`, async function () { + // This test is flaky on Windows CI and we don't know why, but the + // purpose of this test is to make sure Electron does not crash so it + // is fine to retry this test for a few times. + this.retries(3) + const contents = (webContents as any).create() as WebContents const originalEmit = contents.emit.bind(contents) contents.emit = (...args) => { return originalEmit(...args) } diff --git a/spec-main/visibility-state-spec.ts b/spec-main/visibility-state-spec.ts index b08cacf59b94..729ff31fecf9 100644 --- a/spec-main/visibility-state-spec.ts +++ b/spec-main/visibility-state-spec.ts @@ -20,6 +20,10 @@ ifdescribe(process.platform !== 'linux')('document.visibilityState', () => { const itWithOptions = (name: string, options: BrowserWindowConstructorOptions, fn: Mocha.Func) => { return it(name, async function (...args) { + // document.visibilityState tests are very flaky, this is probably because + // Electron implements it via async IPC messages. + this.retries(3) + w = new BrowserWindow({ ...options, paintWhenInitiallyHidden: false,