Closed EarthyOrange closed 2 years ago
TAP comments are meant to only be one line. It seems like a bug that it keeps the newlines at all, tbh.
The multi-line comment is useful. Can just the excess new-lines be removed?
It would break TAP formatters - the whole point of tape is that it produces TAP-compliant output.
The current implementation is still compliant with the TAP protocol's requirement of a comment being a single line. If a multi-line comment is being detected then each line is being emitted separately as a comment.
ah yes, you're right, we do have tests covering multiline comments. Your "current output" confused me because it omits the leading #
:-)
What happens if you try:
t.comment(
dedent(`
When:
- Condition 1
- Condition 2`),
);
in other words, remove the extra trailing newline from your string input.
I still get the Current Output
mentioned in the issue description.
That's not what I see - with this file:
var test = require('tape');
var dedent = require('dedent');
test('test #1', (t) => {
t.comment(
dedent(`
When:
- Condition 1
- Condition 2
`),
);
// Setup Code
t.comment('Then:');
// Assertions
t.end();
});
whether run through node
or tape
, I get this output:
TAP version 13
# test #1
# When:
# - Condition 1
# - Condition 2
# Then:
1..0
# tests 0
# pass 0
# ok
Are you sure there's not something about your shell environment affecting the output? Are you perhaps using zsh and setopt
has a bunch of options in it?
I am using the tap-difflet module to pretty print the results. Maybe it is printing the comments with extra new lines. I will look in to that.
Ah, that's almost certainly the case - and explains why your "current output" is missing the leading #
marks.
I'll close this for now, but will be happy to reopen if there's something actionable for tape
.
Given below code:
Current Output
Expected Output
Why is an extra new line inserted between every line of a multi-line comment? Can the excessive new line insertion be reduced?
https://github.com/substack/tape/blob/master/lib/test.js#L165