Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/internal/test_runner/reporter/junit.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const inspectOptions = { __proto__: null, colors: false, breakLength: Infinity }
const HOSTNAME = hostname();

function escapeAttribute(s = '') {
return escapeContent(RegExpPrototypeSymbolReplace(/"/g, RegExpPrototypeSymbolReplace(/\n/g, s, '
'), '"'));
return RegExpPrototypeSymbolReplace(/"/g, RegExpPrototypeSymbolReplace(/\n/g, escapeContent(s), '
'), '"');
}

function escapeContent(s = '') {
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/test-runner/output/junit_quote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Flags: --test --test-reporter=junit
'use strict';
const test = require('node:test');

test('quote"only', () => {});
test('quote"only', () => {});
test('amp&and"quote"', () => {});
test('lt<and"quote', () => {});
test('line\n"break', () => {});
16 changes: 16 additions & 0 deletions test/fixtures/test-runner/output/junit_quote.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<testsuites>
<testcase name="quote&quot;only" time="*" classname="test" file="*"/>
<testcase name="quote&amp;quot;only" time="*" classname="test" file="*"/>
<testcase name="amp&amp;and&quot;quote&quot;" time="*" classname="test" file="*"/>
<testcase name="lt&lt;and&quot;quote" time="*" classname="test" file="*"/>
<testcase name="line&#10;&quot;break" time="*" classname="test" file="*"/>
<!-- tests 5 -->
<!-- suites 0 -->
<!-- pass 5 -->
<!-- fail 0 -->
<!-- cancelled 0 -->
<!-- skipped 0 -->
<!-- todo 0 -->
<!-- duration_ms * -->
</testsuites>
11 changes: 11 additions & 0 deletions test/test-runner/test-output-junit-quote.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Test that the output of test-runner/output/junit_quote.js matches
// test-runner/output/junit_quote.snapshot
import '../common/index.mjs';
import * as fixtures from '../common/fixtures.mjs';
import { spawnAndAssert, junitTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js';

ensureCwdIsProjectRoot();
await spawnAndAssert(
fixtures.path('test-runner/output/junit_quote.js'),
junitTransform,
);
Loading