This repository has been archived by the owner on Apr 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from Lootjs/feat/junit-report
added junit report
- Loading branch information
Showing
4 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const { consoleError, consoleInfo } = require('../helpers/console'); | ||
const filename = 'yaspeller_report.junit.xml'; | ||
/** | ||
* @param {number} ms | ||
* @returns {number} | ||
*/ | ||
const msToSec = (ms) => ms / 1000; | ||
|
||
module.exports = { | ||
name: 'junit', | ||
onComplete(data) { | ||
try { | ||
const header = '<?xml version="1.0" encoding="UTF-8"?>\n<testsuites><testsuite name="speller" time="">\n'; | ||
const footer = '\n</testsuite></testsuites>'; | ||
const items = data.map(([, item]) => { | ||
const errors = item.data.map(error => | ||
`<error message="${error.word} ${error.suggest ? '-> ' + error.suggest.join(', ') : ''}"/>` | ||
).join(''); | ||
return `<testcase classname="${item.resource}" name="${item.resource}" file="${item.resource}" time="${msToSec(item.time)}"> | ||
${errors} | ||
</testcase>`; | ||
}).join('\n'); | ||
fs.writeFileSync(filename, header + items + footer); | ||
consoleInfo(`Junit report: ./${filename}`); | ||
} catch (e) { | ||
consoleError(e); | ||
} | ||
} | ||
}; |