monocart-reporter 2.6.5 → 2.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -108,10 +108,45 @@ const generateGlobalCoverageReport = async (reporterOptions) => {
108
108
  }
109
109
 
110
110
  // coverageResults: type, reportPath, name, watermarks, summary, files
111
-
112
111
  // showing list props: global, name, path, title
113
112
 
114
- // console.log('global coverage report', report);
113
+ // there is no reportPath if only raw
114
+ const reportPath = coverageResults.reportPath;
115
+
116
+ const artifact = {
117
+ global: true,
118
+ type: 'coverage',
119
+ name: coverageResults.name,
120
+ path: reportPath
121
+ };
122
+
123
+ const reports = {};
124
+ const { reportGroup, outputDir } = coverageReport.options;
125
+ if (reportGroup) {
126
+ reportGroup.forEach((group) => {
127
+ group.forEach((o, k) => {
128
+ reports[k] = o;
129
+ });
130
+ });
131
+ }
132
+
133
+ if (reports.raw) {
134
+ const rawDir = path.resolve(outputDir, reports.raw.outputDir || 'raw');
135
+ artifact.rawDir = Util.relativePath(rawDir, reporterOptions.outputDir);
136
+ }
137
+
138
+ return artifact;
139
+ };
140
+
141
+ const mergeGlobalCoverageReport = async (coverageRawList, reporterOptions) => {
142
+ const coverageOptions = await getGlobalCoverageOptions(reporterOptions);
143
+ coverageOptions.inputDir = coverageRawList;
144
+
145
+ const coverageReport = MCR(coverageOptions);
146
+ const coverageResults = await coverageReport.generate();
147
+ if (!coverageResults) {
148
+ return;
149
+ }
115
150
 
116
151
  const reportPath = coverageResults.reportPath;
117
152
  if (reportPath && fs.existsSync(reportPath)) {
@@ -128,5 +163,6 @@ const generateGlobalCoverageReport = async (reporterOptions) => {
128
163
  module.exports = {
129
164
  addCoverageReport,
130
165
  attachCoverageReport,
131
- generateGlobalCoverageReport
166
+ generateGlobalCoverageReport,
167
+ mergeGlobalCoverageReport
132
168
  };
package/lib/visitor.js CHANGED
@@ -511,6 +511,9 @@ class Visitor {
511
511
  return;
512
512
  }
513
513
 
514
+ // fixed expected image path
515
+ this.expectedAttachmentHandler(item, attachments);
516
+
514
517
  if (item.body) {
515
518
  if (!item.path) {
516
519
  this.saveAttachmentBodyHandler(item, i, caseId);
@@ -555,6 +558,51 @@ class Visitor {
555
558
  }
556
559
  }
557
560
 
561
+ getImageCategory(item) {
562
+ if (item.contentType && item.contentType.startsWith('image/')) {
563
+ if (item.name) {
564
+ const match = item.name.match(/^(.*)-(expected|actual|diff)(\.[^.]+)?$/);
565
+ if (match) {
566
+ // , name, category, extension
567
+ return match[2];
568
+ }
569
+ }
570
+ }
571
+ }
572
+
573
+ expectedAttachmentHandler(item, attachments) {
574
+ const category = this.getImageCategory(item);
575
+ if (category !== 'expected') {
576
+ return;
577
+ }
578
+
579
+ const actualItem = attachments.find((it) => {
580
+ if (it.retry !== item.retry) {
581
+ return false;
582
+ }
583
+ const c = this.getImageCategory(it);
584
+ if (c === 'actual') {
585
+ return true;
586
+ }
587
+ return false;
588
+ });
589
+ if (!actualItem) {
590
+ return;
591
+ }
592
+
593
+ // console.log(item, actualItem);
594
+
595
+ const itemDir = path.dirname(actualItem.path);
596
+ const itemPath = path.resolve(itemDir, item.name);
597
+
598
+ if (fs.existsSync(itemPath)) {
599
+ item.path = itemPath;
600
+ }
601
+
602
+ // no need copy the expected file, it exists
603
+
604
+ }
605
+
558
606
  reportHandler(item, itemName, title) {
559
607
 
560
608
  const definition = Util.attachments[itemName];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monocart-reporter",
3
- "version": "2.6.5",
3
+ "version": "2.7.1",
4
4
  "description": "A playwright test reporter. Shows suites/cases/steps with tree style, markdown annotations, custom columns/formatters/data collection visitors, console logs, style tags, send email.",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -46,27 +46,27 @@
46
46
  "koa": "^2.15.3",
47
47
  "koa-static-resolver": "^1.0.6",
48
48
  "lz-utils": "^2.1.0",
49
- "monocart-coverage-reports": "^2.10.2",
49
+ "monocart-coverage-reports": "^2.10.3",
50
50
  "monocart-locator": "^1.0.2",
51
51
  "nodemailer": "^6.9.14"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@babel/code-frame": "^7.24.7",
55
- "@playwright/test": "^1.46.0",
55
+ "@playwright/test": "^1.46.1",
56
56
  "ansi-to-html": "^0.7.2",
57
57
  "async-tick": "^1.0.0",
58
58
  "autolinker": "^4.0.0",
59
- "axios": "^1.7.3",
59
+ "axios": "^1.7.5",
60
60
  "commander": "^12.1.0",
61
61
  "dotenv": "^16.4.5",
62
- "eslint": "^9.8.0",
62
+ "eslint": "^9.9.1",
63
63
  "eslint-config-plus": "^2.0.2",
64
64
  "eslint-plugin-html": "^8.1.1",
65
65
  "eslint-plugin-vue": "^9.27.0",
66
66
  "file-saver": "^2.0.5",
67
67
  "github-markdown-css": "^5.6.1",
68
- "marked": "^14.0.0",
69
- "mermaid": "^10.9.1",
68
+ "marked": "^14.1.0",
69
+ "mermaid": "^11.0.2",
70
70
  "mitt": "^3.0.1",
71
71
  "monocart-code-viewer": "^1.1.4",
72
72
  "monocart-formatter": "^3.0.0",
@@ -74,7 +74,7 @@
74
74
  "open": "8.4.2",
75
75
  "sanitize-filename": "^1.6.3",
76
76
  "stack-utils": "^2.0.6",
77
- "stylelint": "^16.8.1",
77
+ "stylelint": "^16.9.0",
78
78
  "stylelint-config-plus": "^1.1.2",
79
79
  "turbogrid": "^3.2.0",
80
80
  "vine-ui": "^3.1.16",