Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
junitxml-to-javascript
Advanced tools
Pluggable jUnit XML reports parser to JavaScript objects
npm install junitxml-to-javascript
const Parser = require("junitxml-to-javascript");
new Parser({customTag: "GENERAL1"})
.parseXMLFile("/tmp/passed.xml")
.then(report => console.log(JSON.stringify(report, null, 2)))
.catch(err => console.error(e.message))
const Parser = require("junitxml-to-javascript");
new Parser({customTag: "GENERAL1"})
.parseXMLString(`<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="1my.package.class.Something" errors="0" test="5" failures="0" skipped="0"
timestamp="20171206T181624+0100" time="116.716">
<properties></properties>
<testcase classname="1my.package.class.Something" name="test00Monitoring" time="0.150">
<system-out>
</system-out>
</testcase>
<testcase classname="1my.package.class.Something" name="test01CreateJob" time="43.254">
<system-out>
</system-out>
</testcase>
</testsuite>`)
.then(e => console.log(JSON.stringify(e, null, 2)))
.catch(e => console.error(e.message))
{
"testsuites": [
{
"name": "1my.package.class.Something",
"timestamp": 1512580584000,
"properties": [],
"testCases": [
{
"name": "test00Monitoring",
"duration": 0.15,
"result": "succeeded",
"message": ""
},
{
"name": "test01CreateJob",
"duration": 43.25,
"result": "succeeded",
"message": ""
}
],
"succeeded": 2,
"tests": 2,
"errors": 0,
"skipped": 0,
"tag": "GENERAL",
"durationSec": 43.4
}
]
}
const Parser = require("junitxml-to-javascript");
const p = new Parser()
You can add your own modifier function that will be called right after the XML
data are transformed to raw JavaScript object using library xml2js-parser
(transformed to match the output of the xml2json
parser). This function:
xml2js-parser
parser const Parser = require("junitxml-to-javascript");
const p = new Parser({modifier : (xmlObject) => {
const x = {};
x.testsuites = xmlObject;
return x;
});
This is useful if your XML is not exactly as expected and you wish to preprocess
const Parser = require("junitxml-to-javascript");
new Parser({customTag: "GENERAL1"})
.parseXMLString(`<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="1my.package.class.Something" errors="0" test="5" failures="0" skipped="0"
timestamp="20171206T181624+0100" time="116.716">
<properties></properties>
<testcase classname="1my.package.class.Something" name="test00Monitoring" time="0.150">
<system-out>
</system-out>
</testcase>
<testcase classname="1my.package.class.Something" name="test01CreateJob" time="43.254">
<system-out>
</system-out>
</testcase>
</testsuite>`)
.then(e => console.log(JSON.stringify(e, null, 2)))
.catch(e => console.error(e.message))
By default parser uses UTF-8 encoding. One can change that:
const Parser = require("junitxml-to-javascript");
new Parser()
.parseXMLFile("/tmp/passed.xml", "utf16")
.then(report => console.log(JSON.stringify(report, null, 2)))
.catch(err => console.error(e.message))
By default parser uses time
attribute of testcase
element and sums all values to get total duration of test suite. However, sometimes it might be needed to use time
attribute from testsuite
element instead. One can change that by specifying sumTestCasesDuration
to be false (default is true):
const Parser = require("junitxml-to-javascript");
new Parser({
sumTestCasesDuration: false
})
.parseXMLFile("/tmp/passed.xml", "utf16")
.then(report => console.log(JSON.stringify(report, null, 2)))
.catch(err => console.error(e.message))
FAQs
Pluggable jUnit XML reports parser to JavaScript objects
The npm package junitxml-to-javascript receives a total of 0 weekly downloads. As such, junitxml-to-javascript popularity was classified as not popular.
We found that junitxml-to-javascript demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.