AleG94 / mocha-suppress-logs

Suppress console output of successful mocha tests
MIT License
12 stars 3 forks source link

Log output for failed tests prints messages out of order when multiple log levels are used #9

Closed vassudanagunta closed 8 months ago

vassudanagunta commented 1 year ago

If multiple log levels (e.g. console.log and console.debug) are used, and a test fails, mocha-suppress-logs prints the messages for each level separately, and thus out of order.

For example, if the code writes messages in this order:

console.info('initializing tree')
console.debug('skipping node X')
console.log('initialized 5 nodes')

on test failure the output is:

initialized 5 nodes
skipping node X
initializing tree

Looking at the implementation, this is the result of capturing log messages for each level separately:

https://github.com/AleG94/mocha-suppress-logs/blob/ec776ce9da881e8c1a1008f5c96cc1222deec961/lib/log-capture.js#L30-L32

which means that on failure each level is written out separately and thus out of order: https://github.com/AleG94/mocha-suppress-logs/blob/ec776ce9da881e8c1a1008f5c96cc1222deec961/index.js#L15-L17

It make sense to fix this bug together with #8. The same code is responsible for both issues.

vassudanagunta commented 1 year ago

@AleG94, between the time I reported issue #8 and this issue, usage has doubled!. But it appears that you are busy with other priorities (I hope you are well).

Would you be willing to either give me write access or to transfer the repo to me? The latter could be temporary and I could transfer it back when your have more time.

AleG94 commented 8 months ago

This was long overdue and I'm sorry for that but it should now be fixed in version 0.4!

vassudanagunta commented 8 months ago

Fix confirmed. Thank you!