Skip to content

Commit 56b9171

Browse files
nachooyaV3RON
andauthored
feat(platform-web): expose ignoreDefaultArgs in browser config (#119)
## Summary - Adds `ignoreDefaultArgs` to `WebBrowserConfigSchema`, accepting either `boolean` or `string[]` to match Playwright's [`LaunchOptions.ignoreDefaultArgs`](https://playwright.dev/docs/api/class-browsertype#browser-type-launch-option-ignore-default-args). - Forwards the value into `browserType.launch()` in the web runner so users can disable Playwright's defaults (e.g. drop `--enable-automation`) or strip individual default args without having to fork the runner. ## Motivation Some test setups need to disable specific Playwright defaults (for example to keep `--enable-automation` off so DRM / EME stacks behave the same way they do in a real browser, or to opt out of Playwright's headless-shell args). Without this option the only workaround is to wrap the platform and re-implement the launch flow. ## Test plan - [x] `nx run @react-native-harness/platform-web:typecheck` passes - [ ] Run a web target with `ignoreDefaultArgs: true` and confirm the browser launches without Playwright's defaults - [ ] Run a web target with `ignoreDefaultArgs: ['--enable-automation']` and confirm only that flag is stripped --------- Co-authored-by: Szymon Chmal <szymon@chmal.it>
1 parent bee4691 commit 56b9171

5 files changed

Lines changed: 10 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
__default__: patch
3+
---
4+
5+
Harness on web can now pass Playwright launch arg overrides through the browser config, so you can turn off defaults like `--enable-automation` without forking the runner.

packages/platform-web/src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const WebBrowserConfigSchema = z.object({
88
headless: z.boolean().default(true),
99
channel: z.string().optional(),
1010
executablePath: z.string().optional(),
11+
ignoreDefaultArgs: z.union([z.boolean(), z.array(z.string())]).optional(),
1112
});
1213

1314
export const WebPlatformConfigSchema = z.object({

packages/platform-web/src/runner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ const getWebRunner = async (
8686
headless: parsedConfig.browser.headless,
8787
channel: parsedConfig.browser.channel,
8888
executablePath: parsedConfig.browser.executablePath,
89+
ignoreDefaultArgs: parsedConfig.browser.ignoreDefaultArgs,
8990
});
9091

9192
const context = await browser.newContext();

website/src/docs/getting-started/configuration.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ A test runner defines how tests are executed on a specific platform. React Nativ
127127
Runner-specific launch options belong inside each runner config via `appLaunchOptions`.
128128
They are passed whenever Harness launches or relaunches the app for that runner.
129129

130+
For `@react-native-harness/platform-web`, browser launch options such as `ignoreDefaultArgs` belong on the browser config passed to `chromium`, `chrome`, `firefox`, or `webkit`.
131+
130132
For detailed installation and configuration instructions, please refer to the platform-specific guides:
131133

132134
- [**Android**](/docs/platforms/android)

website/src/docs/platforms/web.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Harness supports all major browser engines through helper factories.
5353
| `headless` | `boolean` | `true` | Whether to run the browser in headless mode. |
5454
| `channel` | `string` | - | Browser channel (e.g., `'chrome'`, `'msedge'`). |
5555
| `executablePath` | `string` | - | Path to a specific browser binary on your system. |
56+
| `ignoreDefaultArgs` | `boolean` or `string[]` | - | Ignore Playwright's default launch arguments, or remove specific ones. |
5657

5758
## UI Testing on Web
5859

0 commit comments

Comments
 (0)