@@ -281,6 +281,32 @@ assert.throws(
281281);
282282```
283283
284+ ### Console output
285+
286+ Output written by tests to stdout or stderr, such as with ` console.log() ` or
287+ ` console.error() ` , can be useful when writing tests, as well as for debugging
288+ them during later maintenance. The output will be supressed by the test runner
289+ (` ./tools/test.py ` ) unless the test fails, but will always be displayed when
290+ running tests directly with ` node ` . For failing tests, the test runner will
291+ include the output along with the failed test assertion in the test report.
292+
293+ Some output can help debugging by giving context to test failures. For example,
294+ when troubleshooting tests that timeout in CI. With no log statements, we have
295+ no idea where the test got hung up. There have been cases where tests fail
296+ without ` console.log() ` , and then pass when its added, so be cautious about its
297+ use, particularly in tests of the I/O and streaming APIs.
298+
299+ Excessive use of console output is discouraged as it can overwhelm the display,
300+ including the Jenkins console and test report displays. Be particularly
301+ cautious of output in loops, or other contexts where output may be repeated many
302+ times in the case of failure.
303+
304+ In some tests, it can be unclear whether a ` console.log() ` statement is required
305+ as part of the test (message tests, tests that check output from child
306+ processes, etc.), or is there as a debug aide. If there is any chance of
307+ confusion, use comments to make the purpose clear.
308+
309+
284310### ES.Next features
285311
286312For performance considerations, we only use a selected subset of ES.Next
0 commit comments