Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fairsplice

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fairsplice - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

src/lib/fixtures/playwright.junit.xml

2

package.json
{
"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;
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc