From 3a7aa682c9239e42e0011bef5e0480afd5c02386 Mon Sep 17 00:00:00 2001 From: protom Date: Sat, 5 Sep 2026 15:46:47 +0200 Subject: [PATCH] test(e2e): warm the dev server before the suite runs --- e2e/global-setup.ts | 39 +++++++++++++++++++++++++++++++++++++++ playwright.config.ts | 1 + 2 files changed, 40 insertions(+) create mode 100644 e2e/global-setup.ts diff --git a/e2e/global-setup.ts b/e2e/global-setup.ts new file mode 100644 index 0000000..f1fd4b1 --- /dev/null +++ b/e2e/global-setup.ts @@ -0,0 +1,39 @@ +import { chromium } from '@playwright/test'; +import { execSync } from 'child_process'; + +// Warms the freshly booted dev server before any test runs. `quasar dev` +// answers HTTP the moment its port is up, but vite still transforms the +// module graph on the first page load - a window in which the first test's +// multi-step onboarding flow can race lazy compilation (observed as the +// create flow never reaching /#/). One full load plus a reload completes +// that work before the suite starts. Uses the same system-chromium +// resolution as the main config (CI falls back to the bundled browser). +const findSystemChromium = (): string | undefined => { + try { + return execSync('command -v chromium').toString().trim() || undefined; + } catch { + return undefined; + } +}; + +const globalSetup = async (): Promise => { + const executablePath = process.env.CHROMIUM_PATH || findSystemChromium(); + const browser = await chromium.launch({ + ...(executablePath ? { executablePath } : {}), + }); + try { + const page = await (await browser.newContext({ baseURL: 'http://localhost:9333' })).newPage(); + await page.goto('/'); + await page + .getByRole('button', { name: 'Get started' }) + .waitFor({ state: 'visible', timeout: 60_000 }); + await page.reload(); + await page + .getByRole('button', { name: 'Get started' }) + .waitFor({ state: 'visible', timeout: 60_000 }); + } finally { + await browser.close(); + } +}; + +export default globalSetup; diff --git a/playwright.config.ts b/playwright.config.ts index ebc968a..35ce509 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -13,6 +13,7 @@ const findSystemChromium = (): string | undefined => { export default defineConfig({ testDir: './e2e', + globalSetup: './e2e/global-setup.ts', fullyParallel: true, forbidOnly: !!process.env.CI, retries: process.env.CI ? 2 : 0,