-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
2,502 additions
and
232 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
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 |
---|---|---|
@@ -1,84 +1,52 @@ | ||
const path = require('path'); | ||
const fs = require("fs"); | ||
|
||
const expect = require('@jest/globals').expect; | ||
const test = require('@jest/globals').test; | ||
const beforeAll = require('@jest/globals').beforeAll; | ||
const afterAll = require('@jest/globals').afterAll; | ||
const describe = require('@jest/globals').describe; | ||
|
||
const converter = require('../src/converter'); | ||
const setup = require("./setup"); | ||
|
||
describe("JUnit converter tests", () => { | ||
|
||
const outDir= './tests/data/tmp'; | ||
const reportDir= './tests/data/result'; | ||
|
||
beforeAll(() => { | ||
if(fs.existsSync(outDir)){ | ||
fs.rmSync(outDir, { recursive: true, force: true }); | ||
} | ||
setup.removeTempDir(); | ||
}); | ||
|
||
// afterAll(() => { | ||
// if(fs.existsSync(outDir)){ | ||
// fs.rmSync(outDir, { recursive: true, force: true }); | ||
// } | ||
// setup.removeTempDir(); | ||
// }); | ||
|
||
function getFilename(file){ | ||
return `${path.parse(file).name}-mochawesome.json` | ||
} | ||
|
||
/** | ||
* @returns {TestReportConverterOptions} | ||
*/ | ||
function createOptions(file, type){ | ||
return { | ||
testFile: path.join(__dirname, `data/source/${file}`), | ||
testType: type, | ||
reportDir: outDir, | ||
reportFilename: getFilename(file), | ||
} | ||
} | ||
|
||
/** | ||
* @param {TestReportConverterOptions} options | ||
* @param {string?} reportFilename | ||
*/ | ||
function compare(options, reportFilename){ | ||
let createdReport = fs.readFileSync(path.join(outDir, options.reportFilename), 'utf8'); | ||
let report = fs.readFileSync(path.join(reportDir, reportFilename ?? options.reportFilename), 'utf8'); | ||
|
||
expect(createdReport.replaceAll(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/g,'')).toBe(report.replaceAll(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/g,'')); | ||
} | ||
|
||
test('convert junit-jenkins.xml', async() => { | ||
let options = createOptions('junit-jenkins.xml', 'junit'); | ||
let options = setup.createOptions('junit-jenkins.xml', 'junit'); | ||
|
||
await converter(options); | ||
compare(options); | ||
setup.compare(options); | ||
}); | ||
|
||
test('convert junit-notestsuites.xml', async() => { | ||
let options = createOptions('junit-notestsuites.xml', 'junit'); | ||
let options = setup.createOptions('junit-notestsuites.xml', 'junit'); | ||
|
||
await converter(options); | ||
compare(options, 'junit-jenkins-mochawesome.json'); | ||
setup.compare(options, 'junit-jenkins-mochawesome.json'); | ||
}); | ||
|
||
test('convert junit-testsuites-noattributes.xml', async() => { | ||
let options = createOptions('junit-testsuites-noattributes.xml', 'junit'); | ||
let options = setup.createOptions('junit-testsuites-noattributes.xml', 'junit'); | ||
|
||
await converter(options); | ||
compare(options, 'junit-jenkins-mochawesome.json'); | ||
setup.compare(options, 'junit-jenkins-mochawesome.json'); | ||
}); | ||
|
||
test('convert junit-mocha-xunit.xml', async() => { | ||
let options = createOptions('junit-mocha-xunit.xml', 'junit') | ||
let options = setup.createOptions('junit-mocha-xunit.xml', 'junit') | ||
|
||
await converter(options); | ||
compare(options); | ||
setup.compare(options); | ||
}); | ||
|
||
}); |
Oops, something went wrong.