Skip to content

Commit 60647fd

Browse files
authored
devex: Add script to bake in local options for Playwright runs (#6668)
## 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)
1 parent bbfada5 commit 60647fd

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"stylelint:fix": "stylelint --cache --fix '{apps,packages,src}/**/*.{css,vue}'",
4444
"stylelint": "stylelint --cache '{apps,packages,src}/**/*.{css,vue}'",
4545
"test:browser": "pnpm exec nx e2e",
46+
"test:browser:local": "cross-env PLAYWRIGHT_LOCAL=1 pnpm test:browser",
4647
"test:unit": "nx run test",
4748
"typecheck": "vue-tsc --noEmit",
4849
"zipdist": "node scripts/zipdist.js",

playwright.config.ts

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
11
import { defineConfig, devices } from '@playwright/test'
2+
import type { PlaywrightTestConfig } from '@playwright/test'
3+
4+
const maybeLocalOptions: PlaywrightTestConfig = process.env.PLAYWRIGHT_LOCAL
5+
? {
6+
// VERY HELPFUL: Skip screenshot tests locally
7+
// grep: process.env.CI ? undefined : /^(?!.*screenshot).*$/,
8+
timeout: 30_000, // Longer timeout for breakpoints
9+
retries: 0, // No retries while debugging. Increase if writing new tests. that may be flaky.
10+
workers: 1, // Single worker for easier debugging. Increase to match CPU cores if you want to run a lot of tests in parallel.
11+
12+
use: {
13+
trace: 'on', // Always capture traces (CI uses 'on-first-retry')
14+
video: 'on' // Always record video (CI uses 'retain-on-failure')
15+
}
16+
}
17+
: {
18+
retries: process.env.CI ? 3 : 0,
19+
use: {
20+
trace: 'on-first-retry'
21+
}
22+
}
223

324
export default defineConfig({
425
testDir: './browser_tests',
526
fullyParallel: true,
627
forbidOnly: !!process.env.CI,
728
reporter: 'html',
8-
// /* // Toggle for [LOCAL] testing.
9-
retries: process.env.CI ? 3 : 0,
10-
use: {
11-
trace: 'on-first-retry'
12-
},
13-
/*/ // [LOCAL]
14-
// VERY HELPFUL: Skip screenshot tests locally
15-
// grep: process.env.CI ? undefined : /^(?!.*screenshot).*$/,
16-
timeout: 30_000, // Longer timeout for breakpoints
17-
retries: 0, // No retries while debugging. Increase if writing new tests. that may be flaky.
18-
workers: 4, // Single worker for easier debugging. Increase to match CPU cores if you want to run a lot of tests in parallel.
19-
20-
use: {
21-
trace: 'on', // Always capture traces (CI uses 'on-first-retry')
22-
video: 'on' // Always record video (CI uses 'retain-on-failure')
23-
},
24-
//*/
29+
...maybeLocalOptions,
2530

2631
globalSetup: './browser_tests/globalSetup.ts',
2732
globalTeardown: './browser_tests/globalTeardown.ts',

0 commit comments

Comments
 (0)