Skip to content

Commit

Permalink
update report
Browse files Browse the repository at this point in the history
  • Loading branch information
santoshshinde2012 committed May 16, 2024
1 parent 0919570 commit 63882da
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions coverage/sonar-report.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<testExecutions version="1">
<file path="tests/lib/SonarReporter.spec.ts">
<testCase name="SonarReporter onTestResult should add test results to testFileResults" duration="0.001" />
<testCase name="SonarReporter onRunComplete should write XML file with test results" duration="0.001" />
<file path="/tests/lib/SonarReporter.spec.ts">
<testCase name="SonarReporter onTestResult should add test results to testFileResults" duration="1" />
<testCase name="SonarReporter onRunComplete should write XML file with test results" duration="0" />
<testCase name="SonarReporter onRunComplete should use default output file if not provided - skipped" duration="0" >
<skipped/>
</testCase>
<testCase name="SonarReporter onRunComplete should use default output file if not provided" duration="0" />
<testCase name="SonarReporter onRunComplete should use provided output file" duration="0.001" />
<testCase name="SonarReporter onRunComplete should use provided output file" duration="0" />
</file>
<file path="tests/helpers/utils.spec.ts">
<testCase name="createFile function should create file with given data" duration="0.001" />
<file path="/tests/helpers/utils.spec.ts">
<testCase name="createFile function should create file with given data" duration="1" />
<testCase name="createFile function should handle error when writing file" duration="0" />
<testCase name="generateXML generates correct XML with test cases of different statuses" duration="0.001" />
<testCase name="generateXML generates correct XML with test cases of different statuses" duration="0" />
<testCase name="generateXML generates correct XML with test cases of 0 duration" duration="0" />
<testCase name="generateXML handles empty testFileResults map" duration="0" />
<testCase name="generateXML handles empty path" duration="0" />
Expand Down
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module.exports = {
roots: ['./tests'],
coveragePathIgnorePatterns: ['/node_modules/', '/tests/'],
collectCoverage: true,
// reporters: ['default', ['./dist/index.js', {
// outputFile: './coverage/sonar-report.xml',
// }]],
reporters: ['default', ['./dist/index.js', {
outputFile: './coverage/sonar-report.xml',
}]],
testEnvironment: 'node',
};
2 changes: 1 addition & 1 deletion src/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function generateXML(testFileResults: Map<string, ITestCase[]>): string {
xml += ` <file path="${path}">\n`;

for (const test of testCases) {
xml += ` <testCase name="${test.name.replace(/"/g, "'")}" duration="${test.duration / 1000}" ${test.status === 'passed' ? '/' : ''}>\n`;
xml += ` <testCase name="${test.name.replace(/"/g, "'")}" duration="${test.duration}" ${test.status === 'passed' ? '/' : ''}>\n`;

if (test.status === 'skipped' || test.status === 'pending') {
xml += ' <skipped/>\n';
Expand Down

0 comments on commit 63882da

Please sign in to comment.