From 2ac41806a243d2176197e42708787c9a5d96972f Mon Sep 17 00:00:00 2001 From: Abhishek S Lal Date: Tue, 18 Nov 2025 12:31:41 +0530 Subject: [PATCH] fix: update result structure to use 'name' instead of 'suitename' in JUnit output (#6120) * fix: update result structure to use 'name' instead of 'suitename' in JUnit output --- packages/bruno-cli/src/commands/run.js | 5 +++-- packages/bruno-cli/src/reporters/junit.js | 2 +- packages/bruno-cli/tests/reporters/junit.spec.js | 6 +++--- .../collection-run-report/collection-run-report.spec.ts | 3 +-- .../cli-junit-report-default-darwin.xml | 8 ++++---- .../cli-junit-report-default-linux.xml | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/bruno-cli/src/commands/run.js b/packages/bruno-cli/src/commands/run.js index c4a7502ee..f9d87d754 100644 --- a/packages/bruno-cli/src/commands/run.js +++ b/packages/bruno-cli/src/commands/run.js @@ -546,7 +546,7 @@ const handler = async function (argv) { let nJumps = 0; // count the number of jumps to avoid infinite loops while (currentRequestIndex < requestItems.length) { const requestItem = cloneDeep(requestItems[currentRequestIndex]); - const { pathname } = requestItem; + const { name, pathname } = requestItem; const start = process.hrtime(); const result = await runSingleRequest( @@ -576,7 +576,8 @@ const handler = async function (argv) { results.push({ ...result, runtime: process.hrtime(start)[0] + process.hrtime(start)[1] / 1e9, - suitename: pathname.replace('.bru', '') + suitename: pathname.replace('.bru', ''), + name }); if (reporterSkipAllHeaders) { diff --git a/packages/bruno-cli/src/reporters/junit.js b/packages/bruno-cli/src/reporters/junit.js index e4a622722..133bfbddf 100644 --- a/packages/bruno-cli/src/reporters/junit.js +++ b/packages/bruno-cli/src/reporters/junit.js @@ -15,7 +15,7 @@ const makeJUnitOutput = async (results, outputPath) => { const totalTests = assertionTestCount + testCount; const suite = { - '@name': result.suitename, + '@name': result.name, '@errors': 0, '@failures': 0, '@skipped': 0, diff --git a/packages/bruno-cli/tests/reporters/junit.spec.js b/packages/bruno-cli/tests/reporters/junit.spec.js index 5d2154a88..f29bc0340 100644 --- a/packages/bruno-cli/tests/reporters/junit.spec.js +++ b/packages/bruno-cli/tests/reporters/junit.spec.js @@ -22,7 +22,7 @@ describe('makeJUnitOutput', () => { const results = [ { description: 'description provided', - suitename: 'Tests/Suite A', + name: 'Tests/Suite A', request: { method: 'GET', url: 'https://ima.test' @@ -47,7 +47,7 @@ describe('makeJUnitOutput', () => { method: 'GET', url: 'https://imanother.test' }, - suitename: 'Tests/Suite B', + name: 'Tests/Suite B', testResults: [ { lhsExpr: 'res.status', @@ -98,7 +98,7 @@ describe('makeJUnitOutput', () => { const results = [ { description: 'description provided', - suitename: 'Tests/Suite A', + name: 'Tests/Suite A', request: { method: 'GET', url: 'https://ima.test' diff --git a/tests/runner/collection-run-report/collection-run-report.spec.ts b/tests/runner/collection-run-report/collection-run-report.spec.ts index 42005729c..e106a91d2 100644 --- a/tests/runner/collection-run-report/collection-run-report.spec.ts +++ b/tests/runner/collection-run-report/collection-run-report.spec.ts @@ -12,7 +12,7 @@ function normalizeJunitReport(xmlContent: string): string { // Replace execution times with fixed value .replace(/time="[^"]*"/g, 'time="0.100"') // Replace file paths with normalized path - .replace(/name="[^"]*\/[^"]*"/g, 'name="/test/path/collection"'); + .replace(/classname="[^"]*\/[^"]*"/g, 'classname="/test/path/collection"'); } test.describe('Collection Run Report Tests', () => { @@ -35,7 +35,6 @@ test.describe('Collection Run Report Tests', () => { // Verify report was generated expect(fs.existsSync(junitOutputPath)).toBe(true); const junitReportContent = fs.readFileSync(junitOutputPath, 'utf8'); - // Snapshot the normalized XML const normalizedJunitReport = normalizeJunitReport(junitReportContent); expect(normalizedJunitReport).toMatchSnapshot('cli-junit-report.xml'); diff --git a/tests/runner/collection-run-report/collection-run-report.spec.ts-snapshots/cli-junit-report-default-darwin.xml b/tests/runner/collection-run-report/collection-run-report.spec.ts-snapshots/cli-junit-report-default-darwin.xml index daf9d79d4..a1a6d34a1 100644 --- a/tests/runner/collection-run-report/collection-run-report.spec.ts-snapshots/cli-junit-report-default-darwin.xml +++ b/tests/runner/collection-run-report/collection-run-report.spec.ts-snapshots/cli-junit-report-default-darwin.xml @@ -1,12 +1,12 @@ - + - + @@ -15,12 +15,12 @@ - + - + diff --git a/tests/runner/collection-run-report/collection-run-report.spec.ts-snapshots/cli-junit-report-default-linux.xml b/tests/runner/collection-run-report/collection-run-report.spec.ts-snapshots/cli-junit-report-default-linux.xml index daf9d79d4..a1a6d34a1 100644 --- a/tests/runner/collection-run-report/collection-run-report.spec.ts-snapshots/cli-junit-report-default-linux.xml +++ b/tests/runner/collection-run-report/collection-run-report.spec.ts-snapshots/cli-junit-report-default-linux.xml @@ -1,12 +1,12 @@ - + - + @@ -15,12 +15,12 @@ - + - +