Created
November 26, 2021 10:01
-
-
Save keksipurkki/8263012b921021134645bf50241b63a0 to your computer and use it in GitHub Desktop.
Parse Junit.xml with JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const Parser = require("junitxml-to-javascript"); | |
function countErrors(testsuites) { | |
let errors = 0; | |
for (const testsuite of testsuites) { | |
errors += testsuite.errors; | |
} | |
return errors; | |
} | |
async function main(...junitReports) { | |
for (const junit of junitReports) { | |
const parser = new Parser(); | |
const { testsuites } = await parser.parseXMLFile(junit); | |
const errors = countErrors(testsuites); | |
console.log(`${junit}: ${errors} errors, ${errors ? "FAIL" : "PASS"}`); | |
} | |
} | |
main(...process.argv.slice(2)).catch((error) => { | |
console.error(error); | |
process.exit(1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment