Skip to content

feat(browser): add providerOptions for browser mode config#1041

Merged
fi3ework merged 3 commits intomainfrom
feat/browser-provider-options
Mar 12, 2026
Merged

feat(browser): add providerOptions for browser mode config#1041
fi3ework merged 3 commits intomainfrom
feat/browser-provider-options

Conversation

@fi3ework
Copy link
Copy Markdown
Member

Summary

  • Add an opaque browser.providerOptions field (Record<string, unknown>) to browser mode config, allowing users to forward provider-specific options through rstest without the framework interpreting them
  • Playwright provider reads providerOptions.launch (spread into browserType.launch()) and providerOptions.context (spread into browser.newContext())
  • Document the config field and Playwright provider options with a satisfies pattern for type safety (en/zh)

Motivation

Resolves the request in #1013 (reply in thread) — users with large projects need to configure Playwright-specific options (e.g. launch timeout) that rstest doesn't expose as first-class config.

Design

providerOptions is an opaque passthrough — the framework does not validate, decode, or translate its contents. The entire bag is forwarded to the provider at both browser launch and context creation time. The provider decides how to interpret the keys.

For Playwright, the convention is:

  • providerOptions.launchbrowserType.launch()
  • providerOptions.contextbrowser.newContext()

Users get type safety via the satisfies pattern with types imported directly from the playwright package — no provider-specific types are exported from @rstest/browser.

Changes

Area Files
Config types packages/core/src/types/config.ts, packages/core/src/config.ts
Validation packages/browser/src/configValidation.ts
Provider interface packages/browser/src/providers/index.ts
Host controller packages/browser/src/hostController.ts
Playwright provider packages/browser/src/providers/playwright/runtime.ts, implementation.ts
Cleanup packages/browser/src/index.ts (removed provider type re-export)
Test packages/browser/tests/playwrightRuntime.test.ts
Docs website/docs/{en,zh}/config/test/browser.mdx, ConfigOverview.tsx
Guidelines AGENTS.md, packages/browser/AGENTS.md

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 11, 2026

Deploying rstest with  Cloudflare Pages  Cloudflare Pages

Latest commit: 995c7a6
Status: ✅  Deploy successful!
Preview URL: https://b694e3de.rstest.pages.dev
Branch Preview URL: https://feat-browser-provider-option.rstest.pages.dev

View logs

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opaque browser.providerOptions passthrough to Browser Mode configuration so users can forward provider-specific options (not interpreted by rstest) to the underlying provider (Playwright).

Changes:

  • Extend core config types/defaults to include browser.providerOptions and normalize it to {}.
  • Thread providerOptions through browser host/controller + provider contracts, validate it as a plain object, and enforce cross-project consistency (deep equality).
  • Update Playwright provider runtime to consume providerOptions.launch/providerOptions.context, add tests, and document usage (EN/ZH) with a new ApiMeta component.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
website/theme/components/ConfigOverview.tsx Adds browser.providerOptions to config overview navigation/grouping.
website/theme/components/ApiMeta.tsx New doc component for “Added/Deprecated/Removed in” metadata.
website/theme/components/ApiMeta.module.scss Styles for the new ApiMeta component.
website/docs/zh/config/test/coverage.mdx Uses ApiMeta instead of inline version text.
website/docs/zh/config/test/browser.mdx Documents providerOptions + Playwright conventions and satisfies typing pattern.
website/docs/en/config/test/coverage.mdx Uses ApiMeta instead of inline version text.
website/docs/en/config/test/browser.mdx Documents providerOptions + Playwright conventions and satisfies typing pattern.
packages/core/tests/core/snapshots/rstest.test.ts.snap Updates snapshots to include providerOptions: {} in normalized browser config.
packages/core/tests/snapshots/config.test.ts.snap Updates config merge snapshot to include providerOptions: {}.
packages/core/src/types/config.ts Adds providerOptions to BrowserModeConfig and NormalizedBrowserModeConfig.
packages/core/src/config.ts Sets default + normalized providerOptions to {}.
packages/browser/tests/playwrightRuntime.test.ts New test verifying passthrough behavior for launch/context options.
packages/browser/src/providers/playwright/runtime.ts Reads providerOptions.launch/providerOptions.context and wraps newContext.
packages/browser/src/providers/playwright/implementation.ts Threads providerOptions into Playwright runtime launch.
packages/browser/src/providers/index.ts Extends provider contracts with providerOptions and documents provider-neutral policy.
packages/browser/src/index.ts Minor cleanup in exports formatting.
packages/browser/src/hostController.ts Stores and forwards providerOptions, and enforces consistency across projects using deep equality.
packages/browser/src/configValidation.ts Validates browser.providerOptions is a plain object in normalized config.
packages/browser/AGENTS.md Adds provider-agnostic design guidelines for Browser Mode.
AGENTS.md Adds guidance to avoid namespace imports unless required by module shape.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Add an opaque `providerOptions` field to `BrowserModeConfig` that lets
users forward provider-specific options (e.g. Playwright launch/context
options) through rstest's browser mode configuration.

- Add `providerOptions: Record<string, unknown>` to config types and
  normalization (defaults to `{}`)
- Pass providerOptions through the full chain: config → launch → newContext
- Playwright provider spreads `.launch` into `browserType.launch()` and
  `.context` into `browser.newContext()`
- Validate providerOptions is a plain object
- Enforce cross-project consistency via `isDeepStrictEqual`
- Remove framework-owned provider type exports (provider-agnostic boundary)
- Add unit test for launch/context passthrough
- Document providerOptions config and Playwright provider options (en/zh)
@fi3ework fi3ework force-pushed the feat/browser-provider-options branch from 608a84a to 995c7a6 Compare March 11, 2026 11:49
@fi3ework fi3ework requested a review from 9aoy March 12, 2026 03:26
@fi3ework fi3ework merged commit 488fb28 into main Mar 12, 2026
10 checks passed
@fi3ework fi3ework deleted the feat/browser-provider-options branch March 12, 2026 05:41
@9aoy 9aoy mentioned this pull request Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants