Meteor-Community-Packages / meteor-browser-tests

A helper package for Meteor test driver packages. Runs client tests in a headless browser.
MIT License
12 stars 21 forks source link

Fix using puppeteer with output files #32

Closed zodern closed 2 years ago

zodern commented 3 years ago

When using the CLIENT_MOCHA_OUTPUT env var, the messages logged in the browser console must be passed to the stderr and stdout functions to be saved to the file. However, when stderr and stdout logged the messages to the server's console they sometimes were not formatted properly so when using puppeteer (and some other browsers) they are no longer used.

This PR changes it back to how it used to use stderr and stdout to fix storing the messages in a file, but it now passes the messages to util.format, which is what Node.js uses to format in many of the console functions.

SimonSimCity commented 3 years ago

@zodern Thanks for the contribution! And sorry for delaying you on this ...

Can you please tell what functions you all tested of the console-methods? (https://console.spec.whatwg.org/)

zodern commented 3 years ago

This is how Node.js handles log, warn, and debug, info, dirxml, and error. I haven't tried other methods (I no longer work on the project that uses this), but they should print the arguments without the extra functionality.

It seems this is at least the 3rd attempt at handling logging from the client, and each time makes a trade off between fixing some use cases and breaking others. It might be better to change how other packages integrate with this package so they can make the decision of using the Node.js console object, or using util.format and storing it in a file.