From 60647fd5b9b9f9e24ab966b4f2b419bcc32c63d9 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Wed, 12 Nov 2025 18:39:41 -0800 Subject: [PATCH] devex: Add script to bake in local options for Playwright runs (#6668) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Try it out: `pnpm test:browser:local` ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6668-devex-Add-script-to-bake-in-local-options-for-Playwright-runs-2aa6d73d36508130b1d6d0b2e79a4641) by [Unito](https://www.unito.io) --- package.json | 1 + playwright.config.ts | 39 ++++++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index e1b43debf..b83fb7d30 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "stylelint:fix": "stylelint --cache --fix '{apps,packages,src}/**/*.{css,vue}'", "stylelint": "stylelint --cache '{apps,packages,src}/**/*.{css,vue}'", "test:browser": "pnpm exec nx e2e", + "test:browser:local": "cross-env PLAYWRIGHT_LOCAL=1 pnpm test:browser", "test:unit": "nx run test", "typecheck": "vue-tsc --noEmit", "zipdist": "node scripts/zipdist.js", diff --git a/playwright.config.ts b/playwright.config.ts index b52daad7f..e080f0c85 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,27 +1,32 @@ import { defineConfig, devices } from '@playwright/test' +import type { PlaywrightTestConfig } from '@playwright/test' + +const maybeLocalOptions: PlaywrightTestConfig = process.env.PLAYWRIGHT_LOCAL + ? { + // VERY HELPFUL: Skip screenshot tests locally + // grep: process.env.CI ? undefined : /^(?!.*screenshot).*$/, + timeout: 30_000, // Longer timeout for breakpoints + retries: 0, // No retries while debugging. Increase if writing new tests. that may be flaky. + workers: 1, // Single worker for easier debugging. Increase to match CPU cores if you want to run a lot of tests in parallel. + + use: { + trace: 'on', // Always capture traces (CI uses 'on-first-retry') + video: 'on' // Always record video (CI uses 'retain-on-failure') + } + } + : { + retries: process.env.CI ? 3 : 0, + use: { + trace: 'on-first-retry' + } + } export default defineConfig({ testDir: './browser_tests', fullyParallel: true, forbidOnly: !!process.env.CI, reporter: 'html', - // /* // Toggle for [LOCAL] testing. - retries: process.env.CI ? 3 : 0, - use: { - trace: 'on-first-retry' - }, - /*/ // [LOCAL] - // VERY HELPFUL: Skip screenshot tests locally - // grep: process.env.CI ? undefined : /^(?!.*screenshot).*$/, - timeout: 30_000, // Longer timeout for breakpoints - retries: 0, // No retries while debugging. Increase if writing new tests. that may be flaky. - workers: 4, // Single worker for easier debugging. Increase to match CPU cores if you want to run a lot of tests in parallel. - - use: { - trace: 'on', // Always capture traces (CI uses 'on-first-retry') - video: 'on' // Always record video (CI uses 'retain-on-failure') - }, - //*/ + ...maybeLocalOptions, globalSetup: './browser_tests/globalSetup.ts', globalTeardown: './browser_tests/globalTeardown.ts',