Skip to content

fix: add screen option to test runner fixtures - #42802

Closed
KARTIK SAHU (yash2277-ctrl) wants to merge 1 commit into
microsoft:mainfrom
yash2277-ctrl:fix-screen-option-test-runner
Closed

KARTIK SAHU (yash2277-ctrl) wants to merge 1 commit into
microsoft:mainfrom
yash2277-ctrl:fix-screen-option-test-runner

Conversation

@yash2277-ctrl

Copy link
Copy Markdown

Description

Fixes #42679

The test runner was silently dropping the screen key when using device descriptors (e.g., devices['iPhone 13']) via est.use(). This caused window.screen dimensions to collapse to viewport size, breaking device emulation for screen readers and media queries.

Changes

  • Added screen fixture to TestOptions in packages/playwright/src/index.ts
  • Added screen to _combinedContextOptions destructure and if-chain
  • Updated PlaywrightTestOptions interface in type definitions
  • Added regression tests for both device descriptor usage and explicit screen configuration

Testing

Added two new test cases in playwright.config.spec.ts:

  1. Test that device descriptors (e.g., devices['iPhone 13']) properly set window.screen dimensions
  2. Test that explicit screen option works independently of �iewport

Impact

This fix ensures screen emulation works consistently in both:

  • Library mode: �rowser.newContext({ ...devices['iPhone 13'] }) ✅ (was already working)
  • Test runner mode: est.use({ ...devices['iPhone 13'] }) ✅ (now fixed)

Related

  • Screen emulation was added in feat(size): emulate window.screen size #5967 (v1.10)
  • paramsThatAllowContextReuse in �rowserContext.ts already includes 'screen'
  • Documentation in emulation.md promises screenSize support in test runner

This contribution was developed with AI assistance (Kiro).

Fixes microsoft#42679

The test runner was silently dropping the 'screen' key when using
device descriptors (e.g., devices['iPhone 13']) via test.use().
This caused window.screen dimensions to collapse to viewport size,
breaking device emulation.

Changes:
- Added 'screen' fixture to TestOptions in index.ts
- Added 'screen' to _combinedContextOptions destructure and if-chain
- Updated PlaywrightTestOptions interface to include screen property
- Added regression tests for device descriptor and explicit screen usage

The fix ensures screen emulation works consistently in both library
mode (browser.newContext) and test runner mode (test.use).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: test runner silently drops the 'screen' key of device descriptors

2 participants