From 34bb054c960bda909c70cb9a67b88e501c3ec550 Mon Sep 17 00:00:00 2001 From: Bartosz Tomczyk Date: Sun, 22 Mar 2026 09:03:03 +0100 Subject: [PATCH] feat: run e2e tests headless by default Previously headless mode was only enabled on CI. Now tests always run headless unless the --headed flag is passed to the run script. Co-Authored-By: Claude Opus 4.6 --- scripts/run-e2e.ts | 13 +++++++++++-- tests/e2e/e2e-helpers.ts | 5 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/run-e2e.ts b/scripts/run-e2e.ts index 80ab6b2e..22c5a786 100644 --- a/scripts/run-e2e.ts +++ b/scripts/run-e2e.ts @@ -10,6 +10,7 @@ interface CliOptions { mode: E2EMode; platform: BrowserPlatform; suite: E2ESuite; + headed: boolean; passthroughArgs: string[]; } @@ -17,6 +18,7 @@ function parseCliOptions(argv: string[]): CliOptions { let mode: E2EMode = "production"; let platform: BrowserPlatform = "chrome"; let suite: E2ESuite = "smoke"; + let headed = false; const passthroughArgs: string[] = []; for (let index = 0; index < argv.length; index += 1) { @@ -72,10 +74,14 @@ function parseCliOptions(argv: string[]): CliOptions { } throw new Error(`Unsupported suite: ${String(value)}`); } + if (arg === "--headed") { + headed = true; + continue; + } passthroughArgs.push(arg); } - return { mode, platform, suite, passthroughArgs }; + return { mode, platform, suite, headed, passthroughArgs }; } async function runCommand(cmd: string[], extraEnv: Record = {}): Promise { @@ -120,12 +126,15 @@ async function main(): Promise { `--outdir=${extensionBuildDir}`, ]); - const sharedE2EEnv = { + const sharedE2EEnv: Record = { E2E_BROWSER: options.platform, E2E_EXTENSION_PATH: extensionBuildDir, E2E_SUITE: options.suite, RUN_E2E: "1", }; + if (options.headed) { + sharedE2EEnv.E2E_HEADED = "1"; + } if (options.mode === "development") { await runCommand( diff --git a/tests/e2e/e2e-helpers.ts b/tests/e2e/e2e-helpers.ts index 6b2e0e03..5ca8e0c2 100644 --- a/tests/e2e/e2e-helpers.ts +++ b/tests/e2e/e2e-helpers.ts @@ -6,6 +6,7 @@ const EXTENSION_PATH = path.resolve( process.env.E2E_EXTENSION_PATH || path.join(__dirname, "../../build/"), ); const IS_CI = process.env.CI === "true" || process.env.CI === "1"; +const IS_HEADED = process.env.E2E_HEADED === "true" || process.env.E2E_HEADED === "1"; export type BrowserType = "chrome" | "firefox"; export type E2ESuite = "smoke" | "full"; @@ -105,7 +106,7 @@ async function launchChrome(): Promise { args.push("--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage"); } return puppeteer.launch({ - headless: IS_CI, + headless: !IS_HEADED, args, defaultViewport: null, }); @@ -323,7 +324,7 @@ async function resolveFirefoxExtensionHost(browser: Browser, extensionId: string async function launchFirefox(): Promise { const browser = await puppeteer.launch({ browser: "firefox", - headless: IS_CI, + headless: !IS_HEADED, defaultViewport: null, });