Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: log playwright browser download progress on stderr #682

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

achingbrain
Copy link
Collaborator

If a browser is downloaded during a test run, playwright will log on stdout.

This can interfere with the calling code if it's trying to parse the output of the program as, for example, JSON.

The fix is to temporarily replace console.log with console.error as that's what the logPolitely function uses to give feedback to the user.

The intention of the playwright maintainers is not for this functionality to be used during a test run so it's unlikely to move to stderr otherwise.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Refactor (non-breaking change that updates existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Comments have been added/updated

If a browser is downloaded during a test run, playwright will log
on stdout.

This can interfere with the calling code if it's trying to parse
the output of the program as, for example, JSON.

The fix is to temporarily replace `console.log` with `console.error`
as that's what the [logPolitely](https://github.com/microsoft/playwright/blob/718bd9b35fd206245401a9ecb320289f427592d9/packages/playwright-core/src/server/registry/browserFetcher.ts#L120)
function uses to give feedback to the user.

The intention of the playwright maintainers is [not for this
functionality to be used during a test run](microsoft/playwright#32487 (comment))
so it's unlikely to move to stderr otherwise.
@achingbrain
Copy link
Collaborator Author

This can be easily verified by removing your browser cache:

$ rm -rf ~/Library/Caches/ms-playwright

...and then directing stdout/stderr to files and examining their contents:

$ npx pw-test ./mocks/test.mocha.js > stdout.txt 2> stderr.txt

@hugomrdias hugomrdias merged commit bb6955c into master Sep 10, 2024
5 checks passed
@hugomrdias hugomrdias deleted the fix/log-download-progress-on-stderr branch September 10, 2024 12:04
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