-
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.
fixing istanbul cobertura report using patch-package
- Loading branch information
Showing
3 changed files
with
136 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
diff --git a/node_modules/istanbul-reports/lib/cobertura/index.js b/node_modules/istanbul-reports/lib/cobertura/index.js | ||
index 85375d4..de55d8d 100644 | ||
--- a/node_modules/istanbul-reports/lib/cobertura/index.js | ||
+++ b/node_modules/istanbul-reports/lib/cobertura/index.js | ||
@@ -11,8 +11,11 @@ class CoberturaReport extends ReportBase { | ||
constructor(opts) { | ||
super(); | ||
|
||
+ opts = opts || {}; | ||
+ | ||
this.cw = null; | ||
this.xml = null; | ||
+ this.timestamp = opts.timestamp || Date.now().toString(); | ||
this.projectRoot = opts.projectRoot || process.cwd(); | ||
this.file = opts.file || 'cobertura-coverage.xml'; | ||
} | ||
@@ -41,7 +44,7 @@ class CoberturaReport extends ReportBase { | ||
'branches-valid': metrics.branches.total, | ||
'branches-covered': metrics.branches.covered, | ||
'branch-rate': metrics.branches.pct / 100.0, | ||
- timestamp: Date.now().toString(), | ||
+ timestamp: this.timestamp, | ||
complexity: '0', | ||
version: '0.1' | ||
}); | ||
@@ -52,15 +55,12 @@ class CoberturaReport extends ReportBase { | ||
} | ||
|
||
onSummary(node) { | ||
- if (node.isRoot()) { | ||
- return; | ||
- } | ||
const metrics = node.getCoverageSummary(true); | ||
if (!metrics) { | ||
return; | ||
} | ||
this.xml.openTag('package', { | ||
- name: escape(asJavaPackage(node)), | ||
+ name: node.isRoot() ? 'main' : escape(asJavaPackage(node)), | ||
'line-rate': metrics.lines.pct / 100.0, | ||
'branch-rate': metrics.branches.pct / 100.0 | ||
}); | ||
@@ -68,7 +68,8 @@ class CoberturaReport extends ReportBase { | ||
} | ||
|
||
onSummaryEnd(node) { | ||
- if (node.isRoot()) { | ||
+ const metrics = node.getCoverageSummary(true); | ||
+ if (!metrics) { | ||
return; | ||
} | ||
this.xml.closeTag('classes'); |
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