From 24b35237a0071dcb7f1284cf2c7a68f51873f940 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 1 Mar 2021 10:49:23 -0500 Subject: [PATCH] test: improve e2e test stability --- packages/vue/__tests__/e2eUtils.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/vue/__tests__/e2eUtils.ts b/packages/vue/__tests__/e2eUtils.ts index a60f797d..2af3befc 100644 --- a/packages/vue/__tests__/e2eUtils.ts +++ b/packages/vue/__tests__/e2eUtils.ts @@ -28,10 +28,17 @@ export function setupPuppeteer() { let browser: puppeteer.Browser let page: puppeteer.Page - beforeEach(async () => { + beforeAll(async () => { browser = await puppeteer.launch(puppeteerOptions) + }) + + beforeEach(async () => { page = await browser.newPage() + await page.evaluateOnNewDocument(() => { + localStorage.clear() + }) + page.on('console', e => { if (e.type() === 'error') { const err = e.args()[0] as any @@ -44,6 +51,10 @@ export function setupPuppeteer() { }) afterEach(async () => { + await page.close() + }) + + afterAll(async () => { await browser.close() })