From 60c98089ccec50575c8b5cf164492a6932ff26ed Mon Sep 17 00:00:00 2001 From: Aleksandr Zabolotnikov <42497203+AlexCannonball@users.noreply.github.com> Date: Wed, 15 Oct 2025 22:26:37 +0300 Subject: [PATCH] test_runner: fix line feed escaping in JUnit Replaces line feed characters with the correct character reference in XML attribute values. --- lib/internal/test_runner/reporter/junit.js | 6 +++--- .../test-runner/output/junit_reporter.snapshot | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/internal/test_runner/reporter/junit.js b/lib/internal/test_runner/reporter/junit.js index d9f9126ba28f85..25f5667c59e273 100644 --- a/lib/internal/test_runner/reporter/junit.js +++ b/lib/internal/test_runner/reporter/junit.js @@ -19,11 +19,11 @@ const inspectOptions = { __proto__: null, colors: false, breakLength: Infinity } const HOSTNAME = hostname(); function escapeAttribute(s = '') { - return escapeContent(RegExpPrototypeSymbolReplace(/"/g, RegExpPrototypeSymbolReplace(/\n/g, s, ''), '"')); + return escapeContent(RegExpPrototypeSymbolReplace(/"/g, RegExpPrototypeSymbolReplace(/\n/g, s, ' '), '"')); } function escapeContent(s = '') { - return RegExpPrototypeSymbolReplace(/ - - + + [Error [ERR_TEST_FAILURE]: Expected values to be strictly equal: true !== false @@ -316,8 +316,8 @@ Error [ERR_TEST_FAILURE]: thrown from callback async throw [Error [ERR_TEST_FAILURE]: customized] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: customized } - - + + [Error [ERR_TEST_FAILURE]: { foo: 1, Symbol(nodejs.util.inspect.custom): [Function: [nodejs.util.inspect.custom]] @@ -413,8 +413,8 @@ Error [ERR_TEST_FAILURE]: bar } - - + + [Error [ERR_TEST_FAILURE]: Expected values to be loosely deep-equal: {