monocart-reporter 2.8.4 → 2.9.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.
@@ -72,7 +72,7 @@ const attachAuditReport = async (runnerResult, testInfo, options = {}) => {
72
72
  return;
73
73
  }
74
74
 
75
- const outputDir = await Util.resolveOutputDir(testInfo);
75
+ const outputDir = Util.resolveOutputDir(testInfo);
76
76
 
77
77
  options = {
78
78
  name: `Lighthouse Report - ${testInfo.title}`,
@@ -5,7 +5,7 @@ const Util = require('../../utils/util.js');
5
5
 
6
6
  const attachCoverageReport = async (data, testInfo, options = {}) => {
7
7
 
8
- const outputDir = await Util.resolveOutputDir(testInfo);
8
+ const outputDir = Util.resolveOutputDir(testInfo);
9
9
  const folderName = `coverage-${Util.resolveTestIdWithRetry(testInfo)}`;
10
10
 
11
11
  // support multiple calls
@@ -59,9 +59,9 @@ const attachCoverageReport = async (data, testInfo, options = {}) => {
59
59
 
60
60
  // ========================================================================================================
61
61
 
62
- const getGlobalCoverageOptions = async (reporterOptions) => {
62
+ const getGlobalCoverageOptions = (reporterOptions) => {
63
63
 
64
- const reporterOutputFile = await Util.resolveOutputFile(reporterOptions.outputFile);
64
+ const reporterOutputFile = Util.resolveOutputFile(reporterOptions.outputFile);
65
65
  const outputDir = path.dirname(reporterOutputFile);
66
66
  const htmlDir = path.resolve(outputDir, 'coverage');
67
67
 
@@ -81,7 +81,7 @@ const getGlobalCoverageOptions = async (reporterOptions) => {
81
81
  const addCoverageReport = async (data, testInfo) => {
82
82
 
83
83
  const reporterOptions = Util.resolveReporterOptions(testInfo);
84
- const coverageOptions = await getGlobalCoverageOptions(reporterOptions);
84
+ const coverageOptions = getGlobalCoverageOptions(reporterOptions);
85
85
 
86
86
  const coverageReport = MCR(coverageOptions);
87
87
  const results = await coverageReport.add(data);
@@ -91,7 +91,7 @@ const addCoverageReport = async (data, testInfo) => {
91
91
 
92
92
  const generateGlobalCoverageReport = async (reporterOptions) => {
93
93
 
94
- const coverageOptions = await getGlobalCoverageOptions(reporterOptions);
94
+ const coverageOptions = getGlobalCoverageOptions(reporterOptions);
95
95
 
96
96
  const coverageReport = MCR(coverageOptions);
97
97
 
@@ -129,7 +129,10 @@ const generateGlobalCoverageReport = async (reporterOptions) => {
129
129
  }
130
130
 
131
131
  if (reports.raw) {
132
- const rawDir = path.resolve(outputDir, reports.raw.outputDir || 'raw');
132
+ let rawDir = path.resolve(outputDir, reports.raw.outputDir || 'raw');
133
+ if (reports.raw.zip) {
134
+ rawDir += '.zip';
135
+ }
133
136
  artifact.rawDir = Util.relativePath(rawDir, reporterOptions.outputDir);
134
137
  }
135
138
 
@@ -137,7 +140,7 @@ const generateGlobalCoverageReport = async (reporterOptions) => {
137
140
  };
138
141
 
139
142
  const mergeGlobalCoverageReport = async (coverageRawList, reporterOptions) => {
140
- const coverageOptions = await getGlobalCoverageOptions(reporterOptions);
143
+ const coverageOptions = getGlobalCoverageOptions(reporterOptions);
141
144
  coverageOptions.inputDir = coverageRawList;
142
145
 
143
146
  const coverageReport = MCR(coverageOptions);
@@ -129,7 +129,7 @@ const attachNetworkReport = async (har, testInfo, options = {}) => {
129
129
  return;
130
130
  }
131
131
 
132
- const outputDir = await Util.resolveOutputDir(testInfo);
132
+ const outputDir = Util.resolveOutputDir(testInfo);
133
133
 
134
134
  options = {
135
135
  // default title
package/lib/utils/util.js CHANGED
@@ -76,18 +76,15 @@ const Util = {
76
76
  return parsed;
77
77
  },
78
78
 
79
- resolveOutputDir: async (testInfo) => {
79
+ resolveOutputDir: (testInfo) => {
80
80
  const reporterOptions = Util.resolveReporterOptions(testInfo);
81
- const outputFile = await Util.resolveOutputFile(reporterOptions.outputFile);
81
+ const outputFile = Util.resolveOutputFile(reporterOptions.outputFile);
82
82
  const outputDir = path.dirname(outputFile);
83
83
  return outputDir;
84
84
  },
85
85
 
86
- resolveOutputFile: async (outputFile) => {
87
- // function to string first
88
- if (typeof outputFile === 'function') {
89
- outputFile = await outputFile();
90
- }
86
+ resolveOutputFile: (outputFile) => {
87
+
91
88
  // then check string
92
89
  if (!outputFile || typeof outputFile !== 'string') {
93
90
  outputFile = getDefaultOptions().outputFile;
@@ -296,6 +293,62 @@ const Util = {
296
293
  return template;
297
294
  },
298
295
 
296
+ getDuration: (dateRanges, durationStrategy) => {
297
+ dateRanges.sort((a, b) => {
298
+ if (a.start === b.start) {
299
+ return a.end - b.end;
300
+ }
301
+ return a.start - b.start;
302
+ });
303
+
304
+ if (durationStrategy === 'exclude-idle') {
305
+
306
+ dateRanges.reduce((prevRange, range) => {
307
+ // same start
308
+ if (range.start === prevRange.start) {
309
+ range.dedupe = true;
310
+ // equal prev
311
+ if (range.end === prevRange.end) {
312
+ return prevRange;
313
+ }
314
+ // great than the prev end, update the end
315
+ prevRange.end = range.end;
316
+ return prevRange;
317
+ }
318
+
319
+ // already in the range
320
+ if (range.end <= prevRange.end) {
321
+ range.dedupe = true;
322
+ return prevRange;
323
+ }
324
+
325
+ // collected, update the end
326
+ if (range.start <= prevRange.end) {
327
+ range.dedupe = true;
328
+ prevRange.end = range.end;
329
+ return prevRange;
330
+ }
331
+
332
+ return range;
333
+
334
+ });
335
+
336
+ const ranges = dateRanges.filter((it) => !it.dedupe);
337
+ // console.log(ranges);
338
+ let duration = 0;
339
+ ranges.forEach((item) => {
340
+ duration += item.end - item.start;
341
+ });
342
+
343
+ return duration;
344
+ }
345
+ // normal
346
+ const dateStart = dateRanges[0].start;
347
+ const endDate = dateRanges[dateRanges.length - 1].end;
348
+ const duration = endDate - dateStart;
349
+ return duration;
350
+ },
351
+
299
352
  mergeOption: function(... args) {
300
353
  const option = {};
301
354
  args.forEach((item) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monocart-reporter",
3
- "version": "2.8.4",
3
+ "version": "2.9.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": {
@@ -20,6 +20,7 @@
20
20
  "scripts": {
21
21
  "link": "node ./scripts/link.js",
22
22
  "test": "npm run link && npx playwright test -c tests",
23
+ "test-example": "npm run link && npx playwright test tests/example -c tests",
23
24
  "test-data": "npm run link && npx playwright test tests/data -c tests",
24
25
  "test-page": "npm run link && npx playwright test tests/home-page -c tests",
25
26
  "test-coverage": "npm run link && npx playwright test tests/report-coverage -c tests",
@@ -46,12 +47,12 @@
46
47
  "koa": "^2.15.3",
47
48
  "koa-static-resolver": "^1.0.6",
48
49
  "lz-utils": "^2.1.0",
49
- "monocart-coverage-reports": "^2.10.9",
50
+ "monocart-coverage-reports": "^2.11.0",
50
51
  "monocart-locator": "^1.0.2",
51
52
  "nodemailer": "^6.9.15"
52
53
  },
53
54
  "devDependencies": {
54
- "@babel/code-frame": "^7.24.7",
55
+ "@babel/code-frame": "^7.25.7",
55
56
  "@playwright/test": "^1.47.2",
56
57
  "ansi-to-html": "^0.7.2",
57
58
  "async-tick": "^1.0.0",
@@ -59,20 +60,21 @@
59
60
  "axios": "^1.7.7",
60
61
  "commander": "^12.1.0",
61
62
  "dotenv": "^16.4.5",
62
- "eslint": "^9.11.0",
63
+ "eslint": "^9.11.1",
63
64
  "eslint-config-plus": "^2.0.2",
64
65
  "eslint-plugin-html": "^8.1.2",
65
66
  "eslint-plugin-vue": "^9.28.0",
66
67
  "file-saver": "^2.0.5",
67
68
  "find-up": "^7.0.0",
68
- "github-markdown-css": "^5.6.1",
69
+ "github-markdown-css": "^5.7.0",
69
70
  "glob": "^11.0.0",
70
71
  "marked": "^14.1.2",
71
- "mermaid": "^11.2.1",
72
+ "mermaid": "^11.3.0",
72
73
  "mitt": "^3.0.1",
73
74
  "monocart-code-viewer": "^1.1.4",
74
75
  "monocart-formatter": "^3.0.0",
75
76
  "nice-ticks": "^1.0.2",
77
+ "node-stream-zip": "^1.15.0",
76
78
  "open": "8.4.2",
77
79
  "sanitize-filename": "^1.6.3",
78
80
  "stack-utils": "^2.0.6",
@@ -81,6 +83,7 @@
81
83
  "supports-color": "^9.4.0",
82
84
  "turbogrid": "^3.2.0",
83
85
  "vine-ui": "^3.1.16",
84
- "ws": "^8.18.0"
86
+ "ws": "^8.18.0",
87
+ "yazl": "^2.5.1"
85
88
  }
86
89
  }