hugomrdias / playwright-test

Run unit tests with several test runners or benchmark inside real browsers with playwright and other Javascript runtimes.
MIT License
100 stars 12 forks source link

fix: log playwright browser download progress on stderr #682

Closed achingbrain closed 1 week ago

achingbrain commented 1 week ago

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.

achingbrain commented 1 week ago

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