Skip to content

Commit cea1e2e

Browse files
committed
Fix service worker E2E test, added enableServiceWorkerForE2E() in PwaPage.ts so this page object flips
1 parent 400eb9b commit cea1e2e

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

test/e2e/helpers/pageObjectModels/PwaPage.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,22 @@ export class PwaPage extends BasePage {
1111
super(page)
1212
}
1313

14+
private static async enableServiceWorkerForE2E(page: Page): Promise<void> {
15+
const enableScript = () => {
16+
window.__disableServiceWorkerForE2E = false
17+
}
18+
19+
await page.addInitScript(enableScript)
20+
try {
21+
await page.evaluate(enableScript)
22+
} catch {
23+
// ignore: evaluate can fail on about:blank in some browsers before first navigation
24+
}
25+
}
26+
1427
static override async init(page: Page): Promise<PwaPage> {
1528
await this.setupPlaywrightGlobals(page)
29+
await this.enableServiceWorkerForE2E(page)
1630
const instance = new PwaPage(page)
1731
await instance.onInit()
1832
return instance

0 commit comments

Comments
 (0)