Skip to content
Merged
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 package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qas-cli",
"version": "0.3.2",
"version": "0.3.3",
"description": "QAS CLI is a command line tool for submitting your automation test results to QA Sphere at https://qasphere.com/",
"type": "module",
"main": "./build/bin/qasphere.js",
Expand Down
9 changes: 9 additions & 0 deletions src/tests/fixtures/junit-xml/empty-system-err.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<testsuites id="" name="" tests="1" failures="0" skipped="0" errors="0" time="1.0">
<testsuite name="splitvale/rune-status/rune-status.spec.ts" timestamp="2025-09-22T20:40:39.036Z" hostname="Marks" tests="1" failures="0" skipped="0" time="1.0" errors="0">
<testcase name="Rune Status: Basic Functionality › QST-2764: Verify that the &quot;ORB&quot; icon appears" classname="splitvale/rune-status/rune-status.spec.ts" time="0.123">
<system-out><![CDATA[[2025-09-22T20:40:39.804Z] [AppManager] [INFO] ViewManager initialized]]></system-out>
<system-err>
</system-err>
</testcase>
</testsuite>
</testsuites>
14 changes: 14 additions & 0 deletions src/tests/junit-xml-parsing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,18 @@ describe('Junit XML parsing', () => {
expect(skippedTests.some(tc => tc.name?.includes('only text content'))).toBe(true)
expect(skippedTests.some(tc => tc.name?.includes('message and text content'))).toBe(true)
})

test('Should handle empty <system-err> and similar empty tags', async () => {
const xmlPath = `${xmlBasePath}/empty-system-err.xml`
const xmlContent = await readFile(xmlPath, 'utf8')

const result = await parseJUnitXml(xmlContent, xmlBasePath)
expect(result.testcases).toHaveLength(1)

// Should parse as success (no failure/error/skipped present)
expect(result.testcases[0].type).toBe('success')

// Message should include system-out content but not fail on empty system-err
expect(result.testcases[0].message).toContain('ViewManager initialized')
})
})
17 changes: 12 additions & 5 deletions src/utils/junit/junitXmlParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ const testCaseSchema = z.object({
name: z.string().optional(),
time: z.string().optional(),
}),
'system-out': z.array(stringContent).optional(),
'system-err': z.array(stringContent).optional(),
// Some JUnit producers emit empty tags like <system-err></system-err> which
// xml2js may parse as empty strings. Accept both object and string forms.
'system-out': z.array(z.union([stringContent, z.string()])).optional(),
'system-err': z.array(z.union([stringContent, z.string()])).optional(),
failure: z.array(failureErrorSchema).optional(),
skipped: z.array(skippedSchema).optional(),
error: z.array(failureErrorSchema).optional(),
Expand Down Expand Up @@ -158,7 +160,11 @@ const getResult = (tcase: z.infer<typeof testCaseSchema>): JUnitResult => {
}

interface GetResultMessageOption {
result?: (Partial<z.infer<typeof failureErrorSchema>> | Partial<z.infer<typeof skippedSchema>>)[]
result?: (
string |
Partial<z.infer<typeof failureErrorSchema>> |
Partial<z.infer<typeof skippedSchema>>
)[]
type?: 'paragraph' | 'code'
}

Expand Down Expand Up @@ -191,8 +197,9 @@ const getAttachments = async (
const promises: Array<{ file: Promise<Buffer>; path: string; filename: string }> = []

for (const contents of out) {
if (contents._) {
const paths = extractAttachmentPaths(contents._)
const text = typeof contents === 'string' ? contents : contents._ ?? ''
if (text) {
const paths = extractAttachmentPaths(text)
paths.forEach((p) =>
promises.push({
file: getFile(p, basePath),
Expand Down