Closed tbeseda closed 1 year ago
I toyed around with preserving whitespace in console.logs in tap-arc
. Ran into 2 problems
The event the parser sends with non-TAP lines is extra
. tap-parser does have a preserveWhitespace
option :thumbsup: -- but extra
doesn't get those empty lines
Another event does though! line
gets almost all lines from the TAP output. so I attempted to filter out non-empty chunks from the line event and print those. Unfortunately, the order isn't guaranteed (the nature of streams), so the blank lines end up being emitted before non-blank lines in a console log
Changing tap-arc to listen to line
like this where I intentionally add a $
to call out lines printed from line
event
parser.on('line', (line) => {
if (line.trim().length === 0) print('$' + line)
})
parser.on('extra', (extra) => {
const stripped = stripAnsi(extra).trim()
const justAnsi = stripped.length === 0 && extra.length > 0
if (!justAnsi) print(`${pad(2)}${extra}`)
})
gives us logs like this
basic arithmetic without messages
✔ should be strictly equal
$
$
$
✖ 2) should be strictly equal
Expected 666 but got 66
At: Test.<anonymous> (/test/create-mixed-tap.js:5:5)
logging inside a test
Logging from a test can be helpful
Multi-line comments
are also
really
cool.
$
You can see that the empty lines from the "logging inside a test" are actually parsed and printed way before the others, in the middle of the previous test group
It would be nice to preserve whitespace in multi-line logs that occur in the middle of tests.
For example, the reporter should print the console.log statement that spans multiple lines with empty lines