diff --git a/lib/internal/test_runner/tap_stream.js b/lib/internal/test_runner/tap_stream.js index efd73e1e9459..d6e883c93588 100644 --- a/lib/internal/test_runner/tap_stream.js +++ b/lib/internal/test_runner/tap_stream.js @@ -127,8 +127,12 @@ class TapStream extends Readable { // In certain places, # and \ need to be escaped as \# and \\. function tapEscape(input) { return StringPrototypeReplaceAll( - StringPrototypeReplaceAll(input, '\\', '\\\\'), '#', '\\#' - ); + StringPrototypeReplaceAll( + StringPrototypeReplaceAll(input, '\\', '\\\\'), + '#', '\\#' + ), + '\n', '\\n' + ); } function jsToYaml(indent, name, value) {