Skip to content

docs(test): fix page.screenshot() call in TestInfo example - #44049

Merged
Yury Semikhatsky (yury-s) merged 1 commit into
microsoft:mainfrom
rodrigogaraujo:docs/testinfo-screenshot-example
Nov 11, 2026
Merged

Yury Semikhatsky (yury-s) merged 1 commit into
microsoft:mainfrom
rodrigogaraujo:docs/testinfo-screenshot-example

Conversation

@rodrigogaraujo

Copy link
Copy Markdown
Contributor

Summary

  • The TestInfo example calls page.screenshot(testInfo.outputPath('screenshot.png')), but page.screenshot() takes an options object. In TypeScript the example does not compile (TS2559: Type 'string' has no properties in common with type 'PageScreenshotOptions'). In JavaScript the test passes, but screenshot.png is not written.
  • Pass the path as { path: testInfo.outputPath('screenshot.png') } and regenerate packages/playwright/types/test.d.ts.

page.screenshot() takes an options object, so the path has to be
passed as `path`. With a string argument the screenshot is not saved.
@rodrigogaraujo

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@yury-s
Yury Semikhatsky (yury-s) merged commit c6c86f7 into microsoft:main Nov 11, 2026
24 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

5229 passed, 637 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

2 flaky ⚠️ [chromium-library] › library/video.spec.ts:762 › screencast › VI-030 should work with video+trace `@chromium-playwright-x64-ubuntu24-64-core-node22`
⚠️ [playwright-test] › ui-mode-trace.spec.ts:448 › should work behind reverse proxy `@macos-latest-node22`

23617 passed, 713 skipped


Merge workflow run.

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.

2 participants