monocart-reporter 2.9.18 → 2.9.19

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.
@@ -87,6 +87,22 @@ const Util = {
87
87
  return s.padStart(l, '0');
88
88
  },
89
89
 
90
+ isNum(num) {
91
+ if (typeof num !== 'number' || isNaN(num)) {
92
+ return false;
93
+ }
94
+ const isInvalid = function(n) {
95
+ if (n === Number.MAX_VALUE || n === Number.MIN_VALUE || n === Number.NEGATIVE_INFINITY || n === Number.POSITIVE_INFINITY) {
96
+ return true;
97
+ }
98
+ return false;
99
+ };
100
+ if (isInvalid(num)) {
101
+ return false;
102
+ }
103
+ return true;
104
+ },
105
+
90
106
  toNum: function(num, toInt) {
91
107
  if (typeof (num) !== 'number') {
92
108
  num = parseFloat(num);
@@ -374,6 +390,43 @@ const Util = {
374
390
 
375
391
  TSF: function(v) {
376
392
  return Util.TF(v, ' ');
393
+ },
394
+
395
+ dateFormat: (date, locale, format) => {
396
+ if (locale) {
397
+ if (format === 'date') {
398
+ return new Intl.DateTimeFormat(locale, {
399
+ year: 'numeric',
400
+ month: 'numeric',
401
+ day: 'numeric'
402
+ }).format(date);
403
+ }
404
+ if (format === 'time') {
405
+ return new Intl.DateTimeFormat(locale, {
406
+ hour: 'numeric',
407
+ minute: 'numeric',
408
+ second: 'numeric'
409
+ }).format(date);
410
+ }
411
+ return new Intl.DateTimeFormat(locale, {
412
+ year: 'numeric',
413
+ month: 'numeric',
414
+ day: 'numeric',
415
+ hour: 'numeric',
416
+ minute: 'numeric',
417
+ second: 'numeric'
418
+ }).format(date);
419
+ }
420
+
421
+ if (format === 'date') {
422
+ return new Date(date).toLocaleDateString();
423
+ }
424
+
425
+ if (format === 'time') {
426
+ return new Date(date).toLocaleTimeString();
427
+ }
428
+
429
+ return new Date(date).toLocaleString();
377
430
  }
378
431
  };
379
432
 
package/lib/utils/pie.js CHANGED
@@ -71,6 +71,7 @@ const generatePieChart = (pieDataList) => {
71
71
  const y = pieHeight / 2;
72
72
  const r = pieHeight / 2 - margin;
73
73
 
74
+ let tests = 0;
74
75
  const list = [];
75
76
  // start from 12 clock
76
77
  let start = 0.75;
@@ -97,6 +98,8 @@ const generatePieChart = (pieDataList) => {
97
98
  d
98
99
  });
99
100
 
101
+ tests += item.value;
102
+
100
103
  });
101
104
 
102
105
  const pies = [];
@@ -116,15 +119,26 @@ const generatePieChart = (pieDataList) => {
116
119
 
117
120
  // legends
118
121
  const legendWidth = 200;
119
- const legendHeight = Math.floor((o.height - margin * 3) / list.length);
120
- const legends = [`<g transform="translate(${pieWidth + margin} ${margin * 1.5})">`];
121
- list.forEach((item, i) => {
122
+ const legendHeight = Math.floor((o.height - margin * 3) / (list.length + 1));
123
+ const legends = [`<g font-family="Helvetica, Arial, sans-serif" transform="translate(${pieWidth + margin} ${margin * 2})">`];
124
+
125
+ const legendList = list.concat([{
126
+ id: 'tests',
127
+ name: 'Total',
128
+ value: tests
129
+ }]);
130
+
131
+ legendList.forEach((item, i) => {
122
132
  const midY = legendHeight * 0.5;
123
133
  legends.push(`<g class="${o.ns}-legend-${item.id}" transform="translate(0 ${legendHeight * i})">`);
124
- legends.push(`<circle cx="10" cy="${midY}" r="10" fill="${item.color}" opacity="0.8" />`);
125
- legends.push(`<text x="30" y="${midY}" alignment-baseline="middle">${item.name}</text>`);
126
- legends.push(`<text x="115" y="${midY}" alignment-baseline="middle" text-anchor="middle">${Util.NF(item.value)}</text>`);
127
- legends.push(`<text x="${legendWidth - margin}" y="${midY}" alignment-baseline="middle" text-anchor="end">${item.percent}</text>`);
134
+ if (item.id !== 'tests') {
135
+ legends.push(`<circle cx="10" cy="${midY}" r="8" fill="${item.color}" opacity="0.8" />`);
136
+ }
137
+ legends.push(`<text x="25" y="${midY}" alignment-baseline="middle">${item.name}</text>`);
138
+ legends.push(`<text x="125" y="${midY}" alignment-baseline="middle" text-anchor="end">${Util.NF(item.value)}</text>`);
139
+ if (item.id !== 'tests') {
140
+ legends.push(`<text x="${legendWidth - margin}" y="${midY}" alignment-baseline="middle" text-anchor="end">${item.percent}</text>`);
141
+ }
128
142
  legends.push('</g>');
129
143
  });
130
144
  legends.push('</g>');
@@ -54,13 +54,13 @@ const getMemUsage = () => {
54
54
  };
55
55
 
56
56
 
57
- const getTickInfo = async () => {
57
+ const getTickInfo = async (timestamp) => {
58
58
  const cpu = await getCpuUsage();
59
59
  const mem = getMemUsage();
60
60
  return {
61
61
  cpu,
62
62
  mem,
63
- timestamp: Date.now()
63
+ timestamp
64
64
  };
65
65
  };
66
66
 
@@ -129,7 +129,7 @@ module.exports = {
129
129
  // setInterval(async () => {
130
130
  // const info = await getSystemInfo();
131
131
  // console.log(info);
132
- // const tick = await getTickInfo();
132
+ // const tick = await getTickInfo(timestamp);
133
133
  // console.log(tick);
134
134
  // }, 1000);
135
135
 
package/lib/utils/util.js CHANGED
@@ -393,6 +393,11 @@ const Util = {
393
393
  return duration;
394
394
  },
395
395
 
396
+ addTimezoneOffset: (timestamp, offset = 0) => {
397
+ // in minutes
398
+ return timestamp + offset * 60 * 1000;
399
+ },
400
+
396
401
  mergeOption: function(... args) {
397
402
  const option = {};
398
403
  args.forEach((item) => {
package/lib/visitor.js CHANGED
@@ -500,13 +500,7 @@ class Visitor {
500
500
  return;
501
501
  }
502
502
 
503
- const attachmentList = attachments.filter((item) => {
504
- // remove _prompt
505
- if (item.name && item.name.startsWith('_prompt-')) {
506
- return false;
507
- }
508
- return true;
509
- }).map((item) => {
503
+ const attachmentList = attachments.map((item) => {
510
504
  // do not change original attachment item for after reporters
511
505
  return {
512
506
  ... item
@@ -599,6 +593,12 @@ class Visitor {
599
593
  const oldPath = item.path;
600
594
  const filename = Util.calculateSha1(oldPath);
601
595
  const ext = path.extname(oldPath);
596
+
597
+ const extname = path.extname(item.name);
598
+ if (!extname) {
599
+ item.fileName = `${item.name}-${filename}${ext}`;
600
+ }
601
+
602
602
  const newPath = path.resolve(attachmentsDir, `${filename}${ext}`);
603
603
  fs.cpSync(oldPath, newPath, {
604
604
  force: true,
@@ -723,6 +723,17 @@ class Visitor {
723
723
  if (item.content) {
724
724
  return;
725
725
  }
726
+
727
+ const excludes = ['_prompt-', '_error-context-'];
728
+ if (item.name) {
729
+ const prefix = excludes.find((it) => item.name.startsWith(it));
730
+ if (prefix) {
731
+ item.link = true;
732
+ // console.log(item);
733
+ return;
734
+ }
735
+ }
736
+
726
737
  if (Util.isTextType(item.contentType)) {
727
738
  item.content = Util.readFileSync(item.path);
728
739
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monocart-reporter",
3
- "version": "2.9.18",
3
+ "version": "2.9.19",
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": {
@@ -44,31 +44,31 @@
44
44
  "dependencies": {
45
45
  "console-grid": "^2.2.3",
46
46
  "eight-colors": "^1.3.1",
47
- "koa": "^2.16.1",
47
+ "koa": "^3.0.0",
48
48
  "koa-static-resolver": "^1.0.6",
49
49
  "lz-utils": "^2.1.0",
50
- "monocart-coverage-reports": "^2.12.4",
50
+ "monocart-coverage-reports": "^2.12.6",
51
51
  "monocart-locator": "^1.0.2",
52
- "nodemailer": "^6.10.1"
52
+ "nodemailer": "^7.0.3"
53
53
  },
54
54
  "devDependencies": {
55
- "@babel/code-frame": "^7.26.2",
55
+ "@babel/code-frame": "^7.27.1",
56
56
  "@playwright/test": "^1.52.0",
57
57
  "ansi-to-html": "^0.7.2",
58
58
  "async-tick": "^1.0.0",
59
- "autolinker": "^4.1.0",
60
- "axios": "^1.8.4",
59
+ "autolinker": "^4.1.5",
60
+ "axios": "^1.9.0",
61
61
  "commander": "^13.1.0",
62
62
  "dotenv": "^16.5.0",
63
- "eslint": "^9.25.1",
63
+ "eslint": "^9.27.0",
64
64
  "eslint-config-plus": "^2.0.2",
65
65
  "eslint-plugin-html": "^8.1.2",
66
- "eslint-plugin-vue": "^10.0.0",
66
+ "eslint-plugin-vue": "^10.1.0",
67
67
  "file-saver": "^2.0.5",
68
68
  "find-up": "^7.0.0",
69
69
  "github-markdown-css": "^5.8.1",
70
70
  "glob": "^11.0.2",
71
- "marked": "^15.0.10",
71
+ "marked": "^15.0.11",
72
72
  "mermaid": "^11.6.0",
73
73
  "mitt": "^3.0.1",
74
74
  "monocart-code-viewer": "^1.1.5",
@@ -78,12 +78,12 @@
78
78
  "open": "8.4.2",
79
79
  "sanitize-filename": "^1.6.3",
80
80
  "stack-utils": "^2.0.6",
81
- "stylelint": "^16.19.0",
81
+ "stylelint": "^16.19.1",
82
82
  "stylelint-config-plus": "^1.1.3",
83
83
  "supports-color": "^10.0.0",
84
84
  "turbogrid": "^3.2.0",
85
85
  "vine-ui": "^3.1.16",
86
- "ws": "^8.18.1",
86
+ "ws": "^8.18.2",
87
87
  "yazl": "^3.3.1"
88
88
  }
89
89
  }