Skip to content

Commit

Permalink
updating code
Browse files Browse the repository at this point in the history
  • Loading branch information
agracio committed Dec 30, 2024
1 parent 9c34013 commit 6bf2582
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
13 changes: 7 additions & 6 deletions src/junit.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ function parseTestSuites(options, testSuites, totalSuitTime, avgSuitTime){

suites.push({
"uuid": parentUUID,
"title": suite.name,
"title": suite.name.replaceAll('Root Suite.', ''),
"fullFile": suite.file,
"file": suiteFile ?? '',
"beforeHooks": [],
Expand Down Expand Up @@ -352,7 +352,12 @@ async function convert(options, suitesRoot){
let duration =
suitesRoot.time
? Number(suitesRoot.time)
: _.sumBy(testSuites, suite => _.sumBy(suite.testcase, function(testCase) { return Number(testCase.time); }));
: _.sumBy(testSuites,function(suite) { return Number(suite.time); });

if(duration === 0){
duration = _.sumBy(testSuites, suite => _.sumBy(suite.testcase, function(testCase) { return Number(testCase.time); }));

}

let tests = suitesRoot.tests
? Number(suitesRoot.tests)
Expand All @@ -368,10 +373,6 @@ async function convert(options, suitesRoot){

let name = suitesRoot.name;

// if(!name && suitesRoot.testsuite.length === 1){
// name = suitesRoot.testsuite[0].name;
// }

results.push(
{
"uuid": crypto.randomUUID(),
Expand Down
16 changes: 4 additions & 12 deletions tests/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,21 @@ function createOptions(file, type){
}
}


/**
* @param {TestReportConverterOptions} options
* @param {string?} reportFilename
* @param {Boolean?} compareJunit
*/
function compare(options, reportFilename, compareJunit){

//createCompareFiles(options, reportFilename, compareJunit);

let createdReport = fs.readFileSync(path.join(outDir, reportFilename ?? options.reportFilename), 'utf8');
createdReport = JSON.parse( JSON.stringify( createdReport ) )

let report = fs.readFileSync(path.join(reportDir, reportFilename ?? options.reportFilename), 'utf8');
report = JSON.parse( JSON.stringify( report ) )
let createdReport = fs.readFileSync(path.join(outDir, reportFilename ?? options.reportFilename), 'utf8').replaceAll('\r', '');
let report = fs.readFileSync(path.join(reportDir, reportFilename ?? options.reportFilename), 'utf8').replaceAll('\r', '') ;

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,''));

Check failure on line 39 in tests/common.js

View workflow job for this annotation

GitHub Actions / test-macos-latest

JUnit converter tests › junit-nested.xml

expect(received).toBe(expected) // Object.is equality - Expected - 3 + Received + 3 @@ -26,11 +26,11 @@ "suites": [ { "uuid": "", "title": "async call from node.js to .net", "fullFile": "C:\\projects\\Dev\\edge-js\\test\\102_node2net.js", - "file": "102_node2net.js", + "file": "C:\\projects\\Dev\\edge-js\\test\\102_node2net.js", "beforeHooks": [], "afterHooks": [], "tests": [ { "title": "[.NET] successfuly marshals data from .net to node.js", @@ -190,11 +190,11 @@ }, { "uuid": "", "title": "async call from node.js to .net.nesting 1.nesting 2", "fullFile": "C:\\projects\\Dev\\edge-js\\test\\102_node2net.js", - "file": "102_node2net.js", + "file": "C:\\projects\\Dev\\edge-js\\test\\102_node2net.js", "beforeHooks": [], "afterHooks": [], "tests": [ { "title": "[.NET] succeeds for hello world", @@ -228,11 +228,11 @@ }, { "uuid": "", "title": "async call from node.js to .net.nesting 1.nesting 2.nesting 3", "fullFile": "C:\\projects\\Dev\\edge-js\\test\\102_node2net.js", - "file": "102_node2net.js", + "file": "C:\\projects\\Dev\\edge-js\\test\\102_node2net.js", "beforeHooks": [], "afterHooks": [], "tests": [ { "title": "[.NET] successfuly marshals data from node.js to .net", at Object.toBe [as compare] (tests/common.js:39:106) at Object.compare (tests/converter.junit.test.js:40:16)

Check failure on line 39 in tests/common.js

View workflow job for this annotation

GitHub Actions / test-ubuntu-latest

JUnit converter tests › junit-nested.xml

expect(received).toBe(expected) // Object.is equality - Expected - 3 + Received + 3 @@ -26,11 +26,11 @@ "suites": [ { "uuid": "", "title": "async call from node.js to .net", "fullFile": "C:\\projects\\Dev\\edge-js\\test\\102_node2net.js", - "file": "102_node2net.js", + "file": "C:\\projects\\Dev\\edge-js\\test\\102_node2net.js", "beforeHooks": [], "afterHooks": [], "tests": [ { "title": "[.NET] successfuly marshals data from .net to node.js", @@ -190,11 +190,11 @@ }, { "uuid": "", "title": "async call from node.js to .net.nesting 1.nesting 2", "fullFile": "C:\\projects\\Dev\\edge-js\\test\\102_node2net.js", - "file": "102_node2net.js", + "file": "C:\\projects\\Dev\\edge-js\\test\\102_node2net.js", "beforeHooks": [], "afterHooks": [], "tests": [ { "title": "[.NET] succeeds for hello world", @@ -228,11 +228,11 @@ }, { "uuid": "", "title": "async call from node.js to .net.nesting 1.nesting 2.nesting 3", "fullFile": "C:\\projects\\Dev\\edge-js\\test\\102_node2net.js", - "file": "102_node2net.js", + "file": "C:\\projects\\Dev\\edge-js\\test\\102_node2net.js", "beforeHooks": [], "afterHooks": [], "tests": [ { "title": "[.NET] successfuly marshals data from node.js to .net", at Object.toBe [as compare] (tests/common.js:39:106) at Object.compare (tests/converter.junit.test.js:40:16)

if(compareJunit){
let junitCreatedReport = fs.readFileSync(path.join(outDir, options.junitReportFilename), 'utf8');
junitCreatedReport = JSON.parse( JSON.stringify( junitCreatedReport ) )
let junitReport = fs.readFileSync(path.join(reportDir, options.junitReportFilename), 'utf8');
junitReport = JSON.parse( JSON.stringify( junitReport ) )
let junitCreatedReport = fs.readFileSync(path.join(outDir, options.junitReportFilename), 'utf8').replaceAll('\r', '');
let junitReport = fs.readFileSync(path.join(reportDir, options.junitReportFilename), 'utf8').replaceAll('\r', '');

expect(junitCreatedReport).toBe(junitReport);
}
Expand Down

0 comments on commit 6bf2582

Please sign in to comment.