fairsplice
Advanced tools
Comparing version 0.4.0 to 0.4.1
{ | ||
"name": "fairsplice", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"module": "index.ts", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -41,2 +41,14 @@ import { describe, it, expect } from "bun:test"; | ||
}); | ||
it("should work with playwright junit xml", async () => { | ||
const xmlString = await Bun.file( | ||
"src/lib/fixtures/playwright.junit.xml" | ||
).text(); | ||
const testCases = parseJunit(xmlString); | ||
expect(testCases).toHaveLength(6); | ||
expect(testCases[0]).toEqual({ | ||
file: "flow/slot-booking/bookSlotAsSiteOwner.spec.ts", | ||
time: 13.651, | ||
}); | ||
}); | ||
}); |
@@ -12,17 +12,31 @@ import { XMLParser } from "fast-xml-parser"; | ||
const testCases: Array<{ file: string; time: number }> = []; | ||
const suites = junit.testsuites.testsuite; | ||
if (suites.length === undefined) { | ||
for (const testcase of suites.testcase) { | ||
testCases.push({ file: testcase.file, time: testcase.time }); | ||
traverseTree(junit, "testcase", (node: any[]) => { | ||
for (const testcase of node) { | ||
let file = testcase.file; | ||
if (file === undefined && testcase.classname !== undefined) { | ||
file = testcase.classname; | ||
} | ||
testCases.push({ file: file, time: testcase.time }); | ||
} | ||
return testCases; | ||
} | ||
}); | ||
for (const testsuite of suites) { | ||
for (const testcase of testsuite.testcase) { | ||
testCases.push({ file: testcase.file, time: testcase.time }); | ||
return testCases; | ||
} | ||
/** | ||
* Traverse a tree and call a callback for all nodes with a given key. | ||
*/ | ||
function traverseTree( | ||
tree: any, | ||
stopKey: string, | ||
callback: (node: any) => void | ||
) { | ||
for (const [key, value] of Object.entries(tree)) { | ||
if (key === stopKey) { | ||
callback(value); | ||
} else if (typeof value === "object") { | ||
traverseTree(value, stopKey, callback); | ||
} | ||
} | ||
return testCases; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33086
18
421